+1 714-215-3097

(Solved) : Using Java Create Program Following 1 First Class Abstract Class Called Weapon Weapon Two Q35571616

USING Java, create a program with the following:

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 andtakes 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 is10.

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

2- The second class is also an abstract class called MeleeWeaponwhich implements ICanHolster (an interface) and extends the Weaponclass.

a-MeleeWeapon has one abstract method called strike.

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

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

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

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

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

c-Remember to implement all the methods that are abstract withinWeapon 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 willextend MeleeWeapon

a-A sword has several characteristics such as blade length, youcan 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 anexample don’t 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 instantiatea Sword, and instantiate a Ray Gun, then output thecalcualtedDamange for each, as well as the range. For the sword youwill also need to output the fact that a sword can beholstered.

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

Leave a Reply

Your email address will not be published. Required fields are marked *