Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help doing this java program. I am finiding trouble doing the attack class. I just need help with the attack, mugwump, and warrior

I need help doing this java program. I am finiding trouble doing the attack class. I just need help with the attack, mugwump, and warrior classes. The Die class is done and is working fine. The BattleSim Class is working as well. I need the codes for the Attack, Mugwump, and Warrior Classes. Thanks.

image text in transcribedimage text in transcribed

image text in transcribedimage text in transcribed

public class BattleSim t public static final int WARRIOR 1; public static final int MUGWUMP 2; ublic static void main(String1 args //Local Variables Warrior warrior; Mugwump mugwump; Scanner stdIn new Scanner(System.in); /game loop do intro); Initialize the Warrior and Mugwump classes and set victor to "none warrior new Warrior(); mugwump new Mugwump); while neither combatant has lost all of their hit points: while(warrior.getHitPoints() && mugwump.getHitPoints() > )( /1. report current stats report(warrior,mugwump); /2. battle! exchangeBlows(warrior,mugwump,stdIn); when a combatant has lost all of their hit points, declare the victor 1f(warrior.getHitPoints() > ) { victory(); else defeat(); /ask to play again while(playAgain(stdIn)); // Thank the user for playing your game System.out.println("Thanks for participating in the Battle Simulator 3050. Have a nice day!"); BattleSim attackChoice) An Attack is a strategy a combatant uses to attempt to damage this/her/its opponent public class Attack private int toHitNUmber private Die damageDi private int damageRolls; private String hitNessage; private String missMessage; private Die d20: To0O Ad instance variables (se UNL for detasts) Sets up an Attack so that it may be executed aparam toHitNumber Number to equal or exceed on a d20 to hit aparam damageDie Die rolled to damage gDonanent aparam damageRolls Number of times to roll the damage die on a hi t aparam hitHessage Message to display when hitting opponent. It should allow for the actual damage number to be added on aparam missMessage Message to display when the attack misses public Attack (int toHit Number, int damageDie, int damageRolls, String hitMessage, String missMessage)f this.toHitNUmber- toHitNumber; this. damageDie = new Die(damageDie); this.damageRollsdamageRolls; this.hitMessagehitMessage; this.missMessagemissMessage; TODO *Attack success is computed by rolling a 20-sided Die and comparing to the toHit Number. If the attack succeeds, the damage die is rolled *a number of times (e.g. for 3d10 damage, a ten-sided damage die is *rolled three times, for 1d8 and eight-sided die is rolled once) and the value after each roll is totaled to compute the damage done by the attack. I the attack misses, it does no damage *Regardless, the appropriate message should be displayed to the console. areturn Total damage done by the attack. public int doAttackO d20 new Die( numberOfSides: 20) if (toHitNUmber >- 12) Die Warrion + IN SIDES: int 2 (read-only + AX SIDES: int 100 (read-only) +DEFAULT SIDES 6 (read-only) +SWORD int 1fread-only + SHIELD : int 2(read-only} - hitPoints: int -sword: Attack shield: Attack d10:Die currentValue int numberOfSides: int Random +Die(numberOfSldes: int) +getNumberOfSides): int +getCurrentValue): int +roll void +Warrior( + getHitPoints0: int +rollinitiative int +takeDamage(damage: int) void + attack(type: int, mugwump : Mugwump) : void BattleSim WARRIOR int 1 fread-only) MUGWUMP : ir -1 rollHitPoints0: int + main(args: String) : void +intro) void +exchangeBlows(warrior Warrior mugwump MugWump, in : Scanner): void Mugwump +reportStatus(warrior: Warrion + CLAWS-int 1 fread-only) +FANGS: int 2 read-only) mugwump MugWump): void +attackChoice(in Scanner): int + initiative(warrior : Warrior mugwump MugWump): void hitPoints int startingHitPoints: int -claws:Attack fangs: Attack d6: Die d10 Die d100:Die + victory0 void + defeat) void +playAgain(in Scanner) : boolean Attack toHitNumber: int damageDie Die damageRolls: int hitMessage: String missMessage: String d20 Die + Mugwumpo +getHitPoints0: int rolllnitiative int +takeDamage(damage: int): void +attack(warrior: Warrior): void Attack( toHitNumber: int, damageDie: int, damageRolls: int, rollHitPoints0: int ai0: int hitMessage: String, missMessage: String) + doAttack): int Starting a Battle Each combatant begins with a number of Hit Points. As long as the player has a positive number of Hit Points she or he has not lost the battle. The Valiant Warrior uses six 10-sided dice (d10) to calculate his or her starting Hit Points. The Mugwump uses ten d10 to calculate his or her starting Hit Points. The battle consists of a number of attack rounds. An Attack Round Each attack round consists of an opportunity for each player to make an attack (unless the second attacker is eliminated prior to his or her tur). Before the round begins, the remaining hit points of each combatant are displayed. To determine the first attacker for the round, both the Mugwump and the Valiant Warrior wll ro a d10. Whoever rolls higher gets to attack first. In the case of a tie, both re-roll. The attacker chooses an attack and attempts to hit his or her opponent by rolling the die. If a hit is made, she or he rolls the appropriate die/dice to determine the damage, and then deducts that damage from the opponents Hit Points. The Valiant Warrior has two possible attacks: His or her Trusty Sword and his or her Shield of Light. The user must decide which one the Warrior uses in each round. His or her Trusty Sword hits the Mugwump on a roll of 12 or greater on a 20-sided die (d20) and rolls two 8-sided dice (d8) for damage. His or her Shield of Light hits the Mugwump on a roll of 8 or greater on a d20 and rolls a 4-sided die (d4) for damage. The evil Mugwump also has two possible attacks: His or her Razor-Sharp Claws and his or her Fangs of Death. His or her Razor-Sharp Claws hit on a roll of 12 or greater on a d20 and rolls two 6-sided dice (d6) for damage. The Mugwump uses this attack 75% of the time. His or her Fangs of Death hit on a roll of 16 or greater on a d20 and rolls three d6 for damage. The Mugwump uses this attack 15% of the time. If the Mugwump does not use either of his or her attacks, she or he licks his or her wounds and heals himself or herself! Ro one d6 and add the result to the Mugwumps Hit Points, not exceeding his or her starting Hit Points After each attack, the attack used, its success or failure, and any resulting damage (or healing) is reported to the console. Battle End The battle ends when one combatants Hit Points goes to zero below or below If the Valiant Warrior succeeds, an appropriately exultant message is displayed. If the Valiant Warrior fails, she or he is mocked by the evil Mugwump. Getting Started While the program is not small, it is fairly straightforward. You should already have a Die class. (One additional requirement if the user requests a Die with fewer than two or more than sone hundred sides, the constructor should set the number of sides to six.) Start by making skeletons for all of the classes. That it, put in all of the methods, with just enough code to make the compiler happy. Don't try to make anything work (yet). Starter skeletons for Attack and BattleSim are provided

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

Beginning Apache Cassandra Development

Authors: Vivek Mishra

1st Edition

1484201426, 9781484201428

More Books

Students also viewed these Databases questions

Question

Would I be a more effective student if I spent less time online?

Answered: 1 week ago