Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lester Zamboni, your micro-managing supervisor, was so impressed by your work last week that he has given you a new task in the development of

Lester Zamboni, your micro-managing supervisor, was so impressed by your work last week that he has given you a new task in the development of Legendary Epics. The starter zone of the game is in development, so your task is to develop the weapon treasure table for this zone.

Some game development background: Most combat-based games have weapon-based objects that are capable of being wielded by a character to do varying amounts of damage to an enemy. However, not all weapons are the same in capability and quality. Lester needs you to code a weapon class using Overloaded Constructors that you can create weapons dynamically, and assign them a quality value, and damage value.

Here is your task:

Create a class definition called Weapon.java. This class definition needs these THREE data fields:

A string called wName, which refers to the name of the weapon. Possible weapons are:

Weapon Type

damage

fork

2

knife

4

stick

1

An integer called wDamage, which refers to the basic damage capabilities of the weapon. Above is a damage table for three types of weapons.

A double named wQuality, which refers to how good the weapon is. Quality is a potential damage bonus or penalty. Below is a table of the three quality conditions that a weapon can have. By default, most weapons are of average quality.

Quality

Damage Multiplier

poor

0.5

average

1

good

1.5

Note: A calculation of the weapons actual damage is made by multiplying wDamage by wQuality, rounded to the nearest integer. For example, a fork of average quality does 2 damage (2*1). A knife of good quality does 6 damage (4*1.5). A stick of poor quality does .5 damage, which should always be rounded using Math.round(), so that damage is expressed as an integer.

Next, write 3 constructors:

A constructor that takes all three parameters for weapons: wName, wDamage, and wQuality, assigning values to each object field.

A constructor that takes two parameters for weapons: wName and wDamage. Assume that when no Quality is provided, a default of average (1) is assigned by the constructor.

A constructor that takes one parameter for weapons: wQuality. Assume that when no name is provided, it will be a stick, which always has a damage value of 1.

Next, write 1 display method showWeapon() that outputs the weapon information onto the console in this format:

You found a that should be capable of damage.

Save all this information in a class definition named Weapon.java.

Next, we need a class that creates 3 weapon objects and displays the damage text description into the console by passing parameters into the Weapon() constructor in your other class :

Create a fork weapon object of good quality (pass 3 parameters).

Create a knife weapon object, passing only two parameters (wName and wDamage).

Create a weapon object that passes a quality of good. (pass 1 parameter).

Save this class as CreateWeapon.java.

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

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions

Question

What are reversing entries, and why are they used?

Answered: 1 week ago

Question

Discuss the history of human resource management (HRM).

Answered: 1 week ago

Question

5. What decision-making model would you advocate to this person?

Answered: 1 week ago

Question

6. What data will she need?

Answered: 1 week ago

Question

1. How did you go about making your selection?

Answered: 1 week ago