Question: Person.java This class will represent a player in our RPG that will contain the following protected variables String name: this will represent the name of

 Person.java This class will represent a player in our RPG that

will contain the following protected variables String name: this will represent the

Person.java This class will represent a player in our RPG that will contain the following protected variables String name: this will represent the name of the player. int health: this represents the health of the player. Spell[] spells: this represents a list of spells that player knows and can use. static int numPeople: this represents the total number of players created. static int currentlyBattlingHeroes: this represents the number of currently living heroes in a battle. static int currentlyBattlingEnemies: this represents the number of living enemies. This class will have the following public methods void attack (Person person, Spell spell) o First, check to see if the current instance of person calling the method is dead. If so, print out "Cannot attack. You are dead! (Hint: What keyword represents the current instance?) o Then, check to see if the person passed in is dead. If so, print out You can't attack [name]! They're already dead!" o Then, you also must check to see if the passed in spell is within the spells array. If the passed in parameter has the same reference (hint hint) as one of the elements in the array, then proceed to the directions below. If it doesn't, print out "Cannot attack. You haven't learned the spell., and exit the method. o This will reduce the person's health by the amount of damage the Spell will cause. o If the person dies because of the damage incurred, there are a couple things we need to check: If the person is an instance of (hint hint) Hero, then reduce currentlyBattlingHeroes and numPeople by one. If the person is an enemy, then reduce currentlyBattlingEnemies and numPeople by one. If the person is neither an enemy or a hero, then decrease numPeople only. static String whoIsWinning() o This will determine who is currently winning based off of our static variables. If there are more currentlyBattlingHeroes than enemies, return a string that says "The heroes are currently winning!. If there are more currentlyBattlingEnemies than heroes, return a string that says "The enemies are currently winning!". void learnSpell(Spell spell) o This method will add a spell to the array of spells available to the person. o If the array is full, print out "name cannot learn anymore spells." getters and setters for all instance variables. This class will have the following constructors Person(String name, int health) o This constructor will initialize name and health with the passed in parameters, and instantiate spells with a length of 5. o This will also increment numPeople by one. Person.java This class will represent a player in our RPG that will contain the following protected variables String name: this will represent the name of the player. int health: this represents the health of the player. Spell[] spells: this represents a list of spells that player knows and can use. static int numPeople: this represents the total number of players created. static int currentlyBattlingHeroes: this represents the number of currently living heroes in a battle. static int currentlyBattlingEnemies: this represents the number of living enemies. This class will have the following public methods void attack (Person person, Spell spell) o First, check to see if the current instance of person calling the method is dead. If so, print out "Cannot attack. You are dead! (Hint: What keyword represents the current instance?) o Then, check to see if the person passed in is dead. If so, print out You can't attack [name]! They're already dead!" o Then, you also must check to see if the passed in spell is within the spells array. If the passed in parameter has the same reference (hint hint) as one of the elements in the array, then proceed to the directions below. If it doesn't, print out "Cannot attack. You haven't learned the spell., and exit the method. o This will reduce the person's health by the amount of damage the Spell will cause. o If the person dies because of the damage incurred, there are a couple things we need to check: If the person is an instance of (hint hint) Hero, then reduce currentlyBattlingHeroes and numPeople by one. If the person is an enemy, then reduce currentlyBattlingEnemies and numPeople by one. If the person is neither an enemy or a hero, then decrease numPeople only. static String whoIsWinning() o This will determine who is currently winning based off of our static variables. If there are more currentlyBattlingHeroes than enemies, return a string that says "The heroes are currently winning!. If there are more currentlyBattlingEnemies than heroes, return a string that says "The enemies are currently winning!". void learnSpell(Spell spell) o This method will add a spell to the array of spells available to the person. o If the array is full, print out "name cannot learn anymore spells." getters and setters for all instance variables. This class will have the following constructors Person(String name, int health) o This constructor will initialize name and health with the passed in parameters, and instantiate spells with a length of 5. o This will also increment numPeople by one

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!