Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USING Java, create a program with the following: (I would like a different answer than the answer on a similar question asked from someone else)

USING Java, create a program with the following: (I would like a different answer than the answer on a similar question asked from someone else)

1-The first class is an abstract class called Weapon:

a-Weapon has two different abstract methods:

i-The first abstract method is void and is called attackType

ii-The second abstract method is void and is called range

b-Weapon has a constructor that accepts the weaponName

c-Weapon also has a regular method that calculatesDamange and takes in attackType (string) and range (int) as parameters.

i-The AttackType can be a rangedAttack or a MeleeAttack

ii-If it is a Melee Attack the range is zero and the damage is 10.

iii-If it is a rangedAttack the higher the range the less the damage (just have a few if or switch statements and make up the numbers.

2- The second class is also an abstract class called MeleeWeapon which implements ICanHolster (an interface) and extends the Weapon class.

a-MeleeWeapon has one abstract method called strike.

b-For now ICanholster is empty but once we fill it with method signatures MeleeWeapon will throw and error so be sure to override each method in ICanholster within MeleeWeapon.

c-remember all the abstract methods within the Weapon class also need to be Overridden within MeleeWeapon.

3- The third class is a regular class called RayGun, which will extend Weapon.

a-RayGun will have a method called fire which will accept the range (hint: range needs to be a field).

b-Please note that you will need to use a super keyword to inherit the constructor that sets the name of the weapon.

c-Remember to implement all the methods that are abstract within Weapon and pass values where it makes sense.

d-we need to output the calculated damage of this weapon

4-The fourth class is a regular class called Sword, which will extend MeleeWeapon

a-A sword has several characteristics such as blade length, you can include this as fields.

b- Any field you include needs a constructor and a getter.

c-Swords can be holstered unlike RayGuns (this is just an example dont focus on the logic).

d-We need to output the calculated damage

5-The fifth class is Main, which will contain your main method (where your output comes from). In this class you will instantiate a Sword, and instantiate a Ray Gun, then output the calcualtedDamange for each, as well as the range. For the sword you will also need to output the fact that a sword can be holstered.

6-Lastly, we have an interface called ICanHolster. a-This interface is simple it simply needs a method called canHolster, much like the example given in class (and uploaded onto blackboard)

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

Database Development For Dummies

Authors: Allen G. Taylor

1st Edition

978-0764507526

More Books

Students also viewed these Databases questions

Question

How much more intense is sound at 40 dB than sound at 0 dB?

Answered: 1 week ago

Question

What do you think is likely to be Liams problem? Discuss.

Answered: 1 week ago

Question

What laws were passed because of domestic violence?

Answered: 1 week ago