Question
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started