Answered step by step
Verified Expert Solution
Question
1 Approved Answer
i need help in java please Create a game where the user must defeat three dragons to pass the trials. Use inheritance to implement the
i need help in java please
Create a game where the user must defeat three dragons to pass the trials. Use inheritance to implement the following class diagram in your program. Fire Dragon Dragon - int fireShots String name + Fire Dragon(String n, int mHp) - int hp + int fireShoto - int maxHp + String toStringo + Dragon(String n, int mHp) + String getName + int getHp Flying Dragon + int attack + void takeDamage(int d) - int swoops + String toStringo + FlyingDragon(String n, int mHp) + int swoop Attack + String toString Dragon Class (Dragon.java) - 1. Constructor - pass in the dragon's name and starting hit points. Assign the mHp value to maxHp and hp. 2. attack return a random amount of damage in the range 3-7. 3. takeDamage - pass in an amount of damage, subtract this value from the dragon's hp. If the hp value is less than zero, reset it to 0. 4. toString - display the dragon's name and hp (hp/maxHp). Fire Dragon Class (Fire Dragon.java) - 1. fireShot if a fire dragon has any shots left, then return a random number in the range 5- 9, otherwise return 0. Decrement the number of shots if one is fired. 2. toString - display the name and hp (by calling super), and the number of shots left. Flying Dragon Class (Flying Dragon.java) 1. swoopAttack - if a flying dragon has any swoop attacks left, then return a random number in the range 5-10, otherwise return 0. Decrement the number of swoops after a swoop attack is done. 2. toString - display the name and hp (by calling super), and the number of swoops left. Main Class (Main.java) - Create one of each of the dragons and give the user some hit points. Allow the user to choose which dragon to attack (if they have any hp). Allow the user to choose to attack with an arrow (random 1-12) or with a sword (random 1-6 + random 1-6). Do that much damage to the dragon they chose to attack. Then choose a random (living) dragon to attack the user. If it is a fire or flying dragon, randomly choose to do a regular attack or their special attack. Do that much damage to the user. Repeat this process until the user defeats all three dragons, or the user dies. Check that all user input is valid. Javadoc all methods. Example Output: 3. Attack Timberjack: 20/20 Swoop attacks remaining: 5 3 What is your name, challenger? Astrid Welcome to dragon training, Astrid You must defeat 3 dragons. Astrid HP: 50 1. Attack Deadly Nadder: 10/10 2. Attack Gronckle: 15/15 Fire Shots remaining: 3 3. Attack Timberjack: 20/20 Swoop attacks remaining: 5 1 Attack with: 1. Arrow (1 012) 2. Sword (2 D6) 2 Attack with: 1. Arrow (1 012) 2. Sword (206) 2 You slash the dragon with your sword. Deadly Nadder smashes you with its tail. Astrid HP: 44 1. Attack Deadly Nadder: 7/10 2. Attack Gronckle: 15/15 Fire Shots remaining: 3 3. Attack Timberjack: 20/20 Swoop attacks remaining: 5 1 You slash the dragon with your sword. Gronckle spews fire at you. Astrid HP: 31 2. Attack Gronckle: 4/15 Fire Shots remaining: 2 3. Attack Timberjack: 11/20 Swoop attacks remaining: 5 2 Attack with: 1. Arrow (1 112) 2. Sword (2 D.) 2 You slash the dragon with your sword. Timberjack swoops down and knocks you over. Astrid HP: 21 3. Attack Timberjack: 11/20 Swoop attacks remaining: 4 3 Attack with: 1. Arrow (1 012) 2. Sword (2 D6) 1 You hit the dragon with an arrow. Timberjack smashes you with its tail. Astrid HP: 40 2. Attack Gronckle: 15/15 Fire Shots remaining: 3 3. Attack Timberjack: 20/20 Swoop attacks remaining: 5 2 Attack with: 1. Arrow (1 D12) 2. Sword (2 D6) 1 You hit the dragon with an arrow. Congratulations Astrid! You defeated all three dragons. You win! Attack with: 1. Arrow (1 012) 2. Sword (206) 2 You slash the dragon with your sword. Gronckle smashes you with its tail. Astrid HP. 37Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started