Question: JAVA. Don't forget UML when creating the two classes below. -Create a Weapon class for your awesome role-playing game you are designing. The Weapon will

JAVA. Don't forget UML when creating the two classes below.

-Create a Weapon class for your awesome role-playing game you are designing. The Weapon will have a damage property to determine how effective it is (Hint: use an integer). The Weapon will also have a name field and a print function to print out all of the above information.

Example Weapon print output: "Hammer - Damage: 7"

Second Example: "Axe - Damage: 13"

-Create a class called Bag which is simply a bag of these weapons with an insert function and a print function. Hint: Just make an array of Weapon of a large size and insert into it. Keep track of current size with a variable internal (hint: private) to the Bag class. Use a for-loop to print out the items (Hint: use the other print function you already created to help you).

Example Bag print output:

You have 2 items in your bag:

Hammer - Damage: 7

Sword - Damage: 13

-Use the main program to fill your bag by calling the insert function a couple of times and then print out the result.

Example code snippet from main:

Bag myBag = new Bag();

myBag.AddWeapon( new Weapon("Hammer", 7));

Weapon mace = new Weapon(); mace.SetName("Mace"); mace.SetPower( 16 ); myBag.AddWeapon( mace ); myBag.PrintAllWeapons();

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!