Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java damage calculation help. Define a Hero class. A Hero should meet the follow

ID: 3926679 • Letter: J

Question

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

Explanation / Answer

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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote