Question: PLEASE USE JAVA. ALSO, I NEED THE TESTER AS WELL AS THE CODE. FINALLY, PLEASE MAKE SURE THE FINAL CODE RUNS AS SHOWN IN THE

PLEASE USE JAVA. ALSO, I NEED THE TESTER AS WELL AS THE CODE. FINALLY, PLEASE MAKE SURE THE FINAL CODE RUNS AS SHOWN IN THE SAMPLE PROGRAM.

Here is the question:

PLEASE USE JAVA. ALSO, I NEED THE TESTER AS WELL AS THE

CODE. FINALLY, PLEASE MAKE SURE THE FINAL CODE RUNS AS SHOWN IN

THE SAMPLE PROGRAM. Here is the question: Question 2: Write a hero

class (Hero.java) that could be used in a role playing game. A

hero has a name, arn amount of health, an amount of mana

Question 2: Write a hero class (Hero.java) that could be used in a role playing game. A hero has a name, arn amount of health, an amount of mana (magic power) and can carry a limited number of items to help him or her on their quest. Your class should have data fields as follows: name - self-explanatory? health- an integer number between 100 (full health) and 0 (expired/deceased) max_items - the maximum number of items that the hero can carry at one time items a list (ArrayList of Strings?) of items currently in the hero's possession. Think of this as the hero's backpack of holding. Once this value is set, it cannot be changed. The class should define the following methods -Constructor (argumented): This constructor should allow for two arguments- a name and a number of items. d not be carrying any items but should have The initial health value for a hero should be 100. A new hero shoul an empty list ready to accept items later on. If the maximum items is greater than 10 or less than 0 throw an IllegalArgumentException (look back in the book if you need a reminder) -Constructor (default): This constructor should allow for zero arguments. The initial health value 100. The hero's name should be Anonymous" and they should have a limit of 2 items in their backpack. -inventoryO: This method takes no arguments and returns (not simply print) a String representation of the items that the hero is currently carrying. If the hero is carr rying nothing then a message should be displayed. take): This method should take one argument - the name of an item that the hero is adding to their inventory The hero can only "take" an item if they are carrying less than their maximum number of items. If the hero is at their maximum carrying capacity, print an appropriate message -drop: This method should take a single argument - the name of an object the hero would like to remove from their inventory. If the user is not currently carrying the requested item then print an appropriate message, otherwise remove the item from inventory takeDamage): This method takes a single integer argument and subtracts that amount trom the hero's health It the resulting hero health would be less than zero, set the health to zero

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!