Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

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

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

2nd Edition

0471180742, 978-0471180746

More Books

Students also viewed these Databases questions

Question

socialist egalitarianism which resulted in wage levelling;

Answered: 1 week ago