Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Just paste your code please! We use Java. Thx CSE 205: Object Oriented Programming Assignment 3 Overview In this assignment you will write a program

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Just paste your code please! We use Java. Thx

CSE 205: Object Oriented Programming Assignment 3 Overview In this assignment you will write a program that will sim- BattleEvent Node Attack Heal QuickAttack PreciseAttack QuickHeal LongHeal Actor BattleEngine Okay, breathe! Everything will be fine. There are a lot of parts to this, but most of them are actually very short Your goal is to write a small engine for running through events that occur in combat in a game This itself isn't a big deal, but there's some complications. For example, when someone is killed, their actions for the rest of the turn should be removed, otherwise you'll have dead pcople attacking you. Other actions may always go first while others will always go last. These will have to properly prioritized The requirements here will list out all critical aspects of each class, but may not explicitly state everything that is required. If a class has a name variable, and another class uses that name for something then you should be able to infer that a getName method is needed. Requirements Your program must do the following in order to receive full credit on this assignment 1. Write a new class called Actor which represents a single fighter in combat. a. b. c. All Actors have a name, and a current amount of health Define a constant STARTINGHEALTH which is equal to 100 The Actor constructor should take a name and set the current health to the constant. Other classes will need to know this Actors name and if they are dead d. i. At what point would someone die in combat? 2. Provide a method that allows this Actor to take damage This should take an int parameter and reduce their health by that much. In order to save space, this will also function as your healing method a. b. i. If the parameter is negative, subtracting it from your health would increase it An Actor cannot have more health than STARTINGHEALTH ii. 3. Define an abstract class called BattleEvent which represents an action being taken by an Actor a. It will need an owner and a target i. These are both Actors It will also need an amount of damage it does and a priority b. i. Both of these should be an int. More on priority later Provide the signature for an abstract void method called doEvent which takes no parameters. c. 4. Write a class called Node which represents a node in a linked list. a. It will need a pointer to the next node in the last as well as the BattleEvent it wil be holding in the list. b. It wil also need the methods common to a linked list node 5. Write a class called BattleEngine which is the actual linked list. a. For fun, and to see where this sort of thing can be helpful, make all variables and methods in this class static i. Remember that you won't want to make the variables inside your methods static, only the ones that would normally be instance variables. b. Like all linked lists, the one variable this class really needs is the head Node 6. Start with three common methods for linked lists: a. b. c. isEmpty count print, which will print the contents of the list (if any) in order 7. Write a method called executeNext a. b. c. This method runs the next event (if any) in the list. Run doEvent on the head Node (actually do the action Remove the head Node from the list (that action has been done so now it's no longer queued) Return the Actor that was the target of the action d. i. If there was no action to execute, return null 8. Write a void method called remove which takes an Actor as a parameter This method needs to remove all Nodes in the list whose events either target, or are owned by the given Actor a. i. This Actor has died, so he shouldn't be attacking anyone and hitting him is just rude 9. Write a void method called add which takes a BattleEvent and adds it to the list. Here's the issue, BattleEvents with a lower priority value need to be placed BEFORE higher ones. a. i. So, an event with a priority of-1 would come before one with a value of 0 ii. Events of the same priority are added in order as normal. iii. So, if the first event added is by Actor One has a priority of 0, the second is added by Actor Two has a priority of 0, and the third is added by Actor Three and has a priority of -1, then the final order in which the Actor would take their action would be: Three, One, Two 10. Write a class called Attack which extends BattleEvent. The constructor should take a target and an owner Damage should be 30 and priority should be 0, which will be the default priority a. b. 11. Override doEvent a. First, it should print out a message indicating [owner] attacks [target] for [damage] That much damage should then be passed to the targets takeDamage method. If that killed the target, print a message that they were defeated and ask the BattleEngine to remove that Actor b. c. 12. Write two classes called QuickAttack and Precise Attack which both extend Attack a. b. c. Quick has a damage of 10 and a priority of-1 Precise does 70 damage, but has a priority of 1 If you make good use of inheritance tricks, these classes can be 10 lines or less! Make sure you don't do more than you have to 13. Write three classes: Heal, QuickHeal, and LongHeal These follow the same exact pattern as the attacks in terms of damage, priority and inheritance, it's just that their damage should be negative in order to heal the target. You will need to have Heal override doEvent again a. b. i. Just make sure it doesn't print that the target was healed for negative damage and you will not need to check if the Actor died. 14. Finally, write your main Assignment3 class. To make things easier, you will need the following static variables a. A scanner b. An ArrayList of Actors currently in the fight c. A variable for the player Actor d. A boolean to track if the fight is sl ongoing e. A boolean to track if the new enemy has been added yet (more on this later) f. An int for the number of turns that have occurred 15. Start with a menu method which has the following options and returns the player's choice: a. Check the status of the combatants b. Quick Attack c. Normal Attack d. Precise Attack e. Quick Heal f. Normal Heal g. Long Heal h. Quit 16. Write a helper method which asks the user for the name of the enemy they want to attack Verify an Actor with that name exists and return it If it doesn't exist, repeat until a valid name is entered a. b. 17. Write a method called runTurn which executes the current set of BattleEvents in the BattleEngine First, increment the number of turns by one Second, if the new enemy hasn't been added yet and this is the third or greater turn, add a new enemy a. b. i. ii. iii. iv. This is a new Actor being added to the ArrayList of combatants This Actor's name is Imp Print a message indicating this Imp has joined the fight Turn off the boolean switch to ensure a new Imp isn't added every turn c. Third, have the enemies add their actions to the engine i. The first enemy (a Goblin we haven't discussed yet) will always do a normal attack targeting the player (an Actor in the ArrayList named Player The Imp will always do a QuickAttack against the player Obviously, they can only attack if they're alive/in the fight. ii. iii. d. Fourth, print out the battle engine using its print method to show the events in order Fifth, run through the events. e. 18. In order to run through the events, you will need a while loop that will run while there are still events left in the engine Run the executeNext method you wrote in the engine and save the Actor it returns If that Actor is dead, remove them from the ArrayList list of combatants. If there is only one combatant left in the ArrayList or the Player is not in there, the fight is over and that boolean should be updated accordingly a. b. c. 19. And to wrap things up, write your main methood. a. Create the player Actor and then add it to the ArrayList. b. Make another Actor called Goblin and add him to the list as wel. c. Get the user's first menu choice and then loop while they haven't selected quit and the fight is still going on If the user chose to display the status, print out the Name and health of each Actor in the list. If they chose any of the other options, then create a new object of the appropriate type (like a QuickAttack) which is owned by the player and has the target returned by your helper method from step 16 and add it to the engine d. e. i. Heals always target the player, no need to ask who to target with those ii. Then, each of these choices should call runTurn. Example Inputs Below are five example runs of the program with the inputs and outputs. Remember, the graders will be testing your program against these as well as their own, so make sure you test these and come up with your own before submitting your program. #1 What do you want to do A. Check Status of the Combatants B. Quick Attack C. Normal Attack D. Precise Attack E. Quick Heal F. Normal Heal G. Long Heal H. Quit Player has 100 health left. Goblin has 100 health left. What do you A. Check Status of the Combatants B. Quick Attack C. Normal Attack D. Precise Attack E. Quick Heal F. Normal Heal G. Long Heal H. Quit want to do? #2 What do you want to do? A. Check Status of the Combatants B. Quick Attack C. Normal Attack D. Precise Attack E. Quick Heal F. Normal Heal G. Long Heal H. Quit Which enemy do you want to attack? (Type their name) Goblin Battle Event queue is: Target: Goblin Damage: 30 Priority: 0 Target: Player Damage: 30 Priority: 0 Player attacks Goblin for 30 damage! Goblin attacks Player for 30 damage! What do you want to do? A. Check Status of the Combatants B. Quick Attack C. Normal Attack D. Precise Attack E. Quick Heal F. Normal Heal G. Long Heal H. Quit Which enemy do you want to attack? (Type their name) Goblin Battle Event queue is: Target: Goblin Damage: 30 Priority: 0 Target: Player Damage: 30 Priority: 0 Player attacks Goblin for 30 damage! Goblin attacks Player for 30 damage! What do you want to do? A. Check Status of the Combatants B. Quick Attack C. Normal Attack D. Precise Attack E. Quick Heal F. Normal Heal G. Long Heal H. Quit Which enemy do you want to attack? (Type their name) GOblin No enemy by that name! Goblin A wandering Imp sneaks up on you and joins the battle against you! Battle Event queue is: Target: Player Damage: 10 Priority: -1 Target: Goblin Damage: 30 Priority: 0 Target: Player Damage: 30 Priority: 0 Imp attacks Player for 10 damage! Player attacks Goblin for 30 damage! Goblin attacks Player for 30 damage! Player is defeated! #4 What do you want to do? A. Check Status of the Combatants B. Quick Attack C. Normal Attack D. Precise Attack E. Quick Heal F. Normal Heal G. Long Heal H. Quit Which enemy do you want to attack? (Type their name) Goblin Battle Event queue is: Target: Player Damage: 30 Priority: 0 Target: Goblin Damage: 70 Priority: 1 Goblin attacks Player for 30 damage! Player attacks Goblin for 70 damage! What do you want to do? A. Check Status of the Combatants B. Quick Attack C. Normal Attack D. Precise Attack E. Quick Heal F. Normal Heal G. Long Heal H. Quit Which enemy do you want to attack? (Type their name) Goblin Battle Event queue is: Target: Goblin Damage: 10 Priority:-1 Target: Player Damage: 30 Priority: 0 Player attacks Goblin for 10 damage! Goblin attacks Player for 30 damage! What do you want to do? A. Check Status of the Combatants B. Quick Attack C. Normal Attack D. Precise Attack E. Quick Heal F. Normal Heal G. Long Heal H. Quit A wandering Imp sneaks up on you and joins the battle against you! Battle Event queue i:s Target: Player Damage: 10 Priority: -1 Target: Player Damage: 30 Priority: 0 Target: Player Damage: -80 Priority: 1 Imp attacks Player for 10 damage! Goblin attacks Player for 30 damage! Player is defeated! #5 What do you want to do? A. Check Status of the Combatants B. Quick Attack C. Normal Attack D. Precise Attack E. Quick Heal F. Normal Heal G. Long Heal H. Quit Which enemy do you want to attack? (Type their name) Goblin Battle Event queue is: Target: Player Damage: 30 Priority: 0 Target: Goblin Damage: 70 Priority: 1 Goblin attacks Player for 30 damage! Player attacks Goblin for 70 damage! What do you want to do? A. Check Status of the Combatants B. Quick Attack C. Normal Attack D. Precise Attack E. Quick Heal F. Normal Heal G. Long Heal H. Quit Which enemy do you want to attack? (Type their name) Goblin Battle Event queue is: Target: Goblin Damage: 10 Priority: -1 Target: Player Damage: 30 Priority: 0 Player attacks Goblin for 10 damage! Goblin attacks Player for 30 damage! What do you want to do? A. Check Status of the Combatants B. Quick Attack C. Normal Attack D. Precise Attack E. Quick Heal F. Normal Heal G. Long Heal H. Quit A wandering Imp sneaks up on you and joins the battle against you! Battle Event queue is: Target: Player Damage: 10 Priority: -1 Target: Player Damage: 10 Priority: -1 Target: Player Damage: 30 Priority: 0 Player heals Player for 10 health! Imp attacks Player for 10 damage! Goblin attacks Player for 30 damage! What do you want to do? A. Check Status of the Combatants B. Quick Attack C. Normal Attack D. Precise Attack E. Quick Heal F. Normal Heal G. Long Heal H. Quit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions