Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description: In this final evaluation, you will be responsible for analyzing and improving your assignment one using your understanding of object orientation. The goal of

Description: In this final evaluation, you will be responsible for analyzing and improving your assignment one using your understanding of object orientation. The goal of this evaluation is to determine how much you have learned over the semester. 1) Perform a code critique on your first assignment: identify ways that the program could be improved and enhanced through object oriented techniques. Comment the code with your suggestions. Once you're finished, change the file extension to .txt to avoid compiler issues.

2) Implement the changes that you have suggested in part 1. Be sure to comment your code.

Assignment 1 code:

import java.util.ArrayList;

public class Main { private ArrayList fellowship; private Characters bilbo; private Characters aragorn; private Characters grimble; private Characters arwen; private Characters mister; //noArgConstructor to instantiate Characters public Main() { bilbo = new Characters("Biblo", "Baggins", 'M', "Hafling", "Rogue"); aragorn = new Characters("Aragorn", "Ellesar", 'M', "Human", "Ranger"); grimble = new Characters("Grimble", "Grumble", 'M', "Gnome", "Wizard"); arwen = new Characters("Arwen", "Undomiel", 'F', "Elf", "Cleric"); mister = new Characters("Mister", "Steve", 'M', "Human", "Bard"); packageCharacters(); showList(); System.out.println(); } //package Characters into an ArrayList public void packageCharacters() { fellowship = new ArrayList(); fellowship.add(bilbo); fellowship.add(aragorn); fellowship.add(grimble); fellowship.add(arwen); fellowship.add(mister); } //display Character attribute public void showList() { for(Characters c : fellowship) { System.out.println(c.show_stats()); } } //display Character messages public void printMessage(String message) { System.out.print(message); } //Affects applied to Grimble public void applyAffect(Characters character) { int damage = character.getRand().nextInt(90) + 10; if(character.getDexterity() > damage) { printMessage(character.getActionMessages()[character.getRand().nextInt(4)]); printMessage(character.getEncouragementMessages()[character.getRand().nextInt(4)]); }else if(character.getDexterity() <= damage) { printMessage(character.getBadHappeningsMessages()[character.getRand().nextInt(4)]); if(character.hp(-(damage - 20 > 0 ? damage - 20 : 0)) == 0) { printMessage(character.getSadMessages()[character.getRand().nextInt(4)]); }else { printMessage(character.getEncouragementMessages()[character.getRand().nextInt(4)]); } } System.out.println(character.show_stats()); } //beginning of journey public void startJourney() { Characters character_1 = anonymousCharacter(); Characters character_2 = anonymousCharacter(); while(character_2 == character_1) { character_2 = anonymousCharacter(); } String narrator_1 = "The Fellowship enter the dark swamp of Guruth-kil. An eerie green mist hangs in the air. "; String char_1 = "\"I don't like the feel of this place.\" whispers " + character_1.getFirst() + "... "; String char_2 = "\"Never fret, master " + character_1.getRace() + ",\" squeaks " + character_2.getFirst() + ", \"you have a " + character_2.getClazz() + " at your side!...\" "; String narrtor_2 = character_2.getFirst() + ", distracted by " + (character_2.getSex() == 'F' ? "her" : "his") + " own ego, steps into a trap!... "; printMessage(narrator_1); printMessage(char_1); printMessage(char_2); printMessage(narrtor_2); applyAffect(character_2); } //retreiver for random Characters public Characters anonymousCharacter() { return fellowship.get(fellowship.get(0).getRand().nextInt(5)); } public static void main (String[]args) { Main m = new Main(); m.startJourney(); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

A Complete Guide To Data Science Essentials

Authors: Miguel

1st Edition

9358684992, 978-9358684995

More Books

Students also viewed these Databases questions

Question

How do our biological rhythms impact daily functioningpg12

Answered: 1 week ago

Question

List the advantages and disadvantages of the pay programs. page 505

Answered: 1 week ago