Java damage calculation help Define a Hero class A Hero shou

Java damage calculation help.

Define a Hero class. A Hero should meet the following specifications:

maxAttack : the maximum attack this hero can make

maxDefense : the maximum defense this hero can make

setters and getters for maxAttack and maxDefense

getAttack : returns a random integer between zero and the maxAttack

getDefense : returns a random integer between zero and the maxDefense In the main method.

create two hero objects, hero1 and hero2. Set their maxAttack and MaxDefense using the corresponding methods. Hero1 is the attacker, hero2 the defender. Get hero1\'s attack and store it in a variable. Get hero2\'s defense and store it in a variable. If the attack is 0, print \"Attacker Missed\" If the block is the same or greater than the attack, print \"Defender Blocked\" If the attack is greater than the block and not 0, print \"Attacker hit for N\" (where N is the difference between the attack and the block) rint the results as shown: Hero 1: Attack = 10 Hero 2: Max Def = 10 Hero 1 attack = 5 Hero 2 defense = 7 Defender Blocked or Hero 1: Attack = 10 Hero 2: Max Def = 10 Hero 1 attack = 9 Hero 2 defense = 1 Attacker hit for 8

Solution

Please find the required program along with its output. Please see the comments against each line to understand the step.

----------------------------------------------

OUTPUT:

Hero 1: Max Attack = 10
Hero 2: Max Defence = 10
Hero 1: Attack = 2
Hero 2: Defence = 9
Defender Blocked

Hero 1: Max Attack = 10
Hero 2: Max Defence = 10
Hero 1: Attack = 9
Hero 2: Defence = 1
Attacker hit for 8

Java damage calculation help. Define a Hero class. A Hero should meet the following specifications: maxAttack : the maximum attack this hero can make maxDefense

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site