Question

Question 1. (Magician.java, Healer.java, Fighter.java, HeroTester.java) Consider the abstract hero class and the three

subclasses shown below.

Review the hero class to see how it works (it’s in the project/package for you already). Your job is to implement

the following subclasses. Each of the subclasses has an extra data field that relates to their specific hero talent.

Some help with these special talents and other methods are below.

Fighter:

‐The fighter has an extra data field called Strength and a method called Berserk. When the fighter calls Berserk

they do damage equal to 1/3 of their existing health BUT they lose 1/4 of their existing health (round to integer

values). Using Berserk costs one Strength point. When a fighter is constructed they have 3 strength points.

‐the dealDamage() method for the fighter does between 7 and 10 points of damage

Magician:

‐The magician has an extra data field called Mana and a method called Lightning. When the magician calls

Lightning the damage they inflict is quadruple what it would have been otherwise. Call the existing dealDamage

function and quadruple the value before dealing it to the enemy. Using Lightning costs 1 Mana point and a

magician has 4 Mana points to start with.

‐the dealDamage() method for the magician does between 4 and 6 points of damage

Healer:

‐The healer has an extra data field called Dexterity and a method called Heal. When the healer calls Heal each

LIVING member of the party receives between 5 and 10 health points (not to pass 100) and each receives one

point back to their special skill (dexterity, mana or strength). Calling Heal costs 2 Dexterity points and a healer

starts with 4 Dexterity. Hint: The heal method determines how many points are restored to each party member’s

health. Let your main method do the actual work of healing the surviving heroes.

‐the dealDamage() method for the Healer does between 3 and 5 points of damage

If your hero is out of special skill points they can only call the base dealDamage() method (i.e., they cannot use

their special skill). Once a hero is dead, they can’t do anything … because, they’re dead.

In addition to any extra accessors and mutators you should override the toString method for easy printing of the

hero state.

Write a tester class that does the following:

Option 1: Write a hard‐coded tester that does the following:

 Create an array of three heroes (one of each type)

 Create an array of 10 goblins (already in the project/package)

 Wage an epic battle between the groups

o Heroes attack first in sequence (i.e., hero[0] attacks first, then hero[1] and so on)

 They attack the goblins in sequence (each hero attacks the first goblin in the array until it

is vanquished and then they move onto the next)

o Goblins attack next in order (goblin[0], then goblin[1] and so on) but they attack a random hero.

 If a hero dies it cannot attack nor be attacked any further, skip it in the rotation. Same

for ex‐goblins.

 At any point, if all the heroes have met their doom, the goblins win. If any of the heroes live and the

goblins are all dispatched, then yay!.

 Your tester should keep you updated on how the battle is progressing by telling you how many goblins

are left, what is the state of your heroes after the round, who has died (if anyone) and when there is a

win condition.

 Heroes have a 40% chance of using their special skill. The other 60% is regular damage. If a hero tries to

use their special skill but they have no special skill points left, they simply do regular damage.

 If you’re stuck, try a battle between 1 hero and 1 goblin to get the mechanics figured out, then move

onto the arrays.

Option 2 (for bragging rights):

Same as option 1 BUT allow the user to select which hero they want to send into battle, which goblin they want

to attack and whether or not to do regular damage or use their special attack. The rules of the game must be

maintained. They cannot attack with dead heroes and cannot attack dead goblins.

***PLEASE post the output of some of your battles to the forum so that people can see how your tester is working.***

I need this done in Java as soon as possible.

Please make it simple as possible
Question 1. (Magician.java, Healer.java, Fighter.java, HeroTester.java) Consider the abstract hero class and the three subcla

100% Review the hero class to see how it works (its in the project/package for you already). Your job is to implement the fo

If your hero is out of special skill points they can only call the base dealDamage) method (i.e, they cannot use their specia

0 0
Add a comment Improve this question Transcribed image text
Answer #1

package Tests;

import java.util.Random;
import java.util.Scanner;

public class DuelMain {

public static void main(String[] args) {
Random battle = new Random();
@SuppressWarnings("resource")
Scanner input = new Scanner(System.in);

int hero, match, restart;

Duel valon = new Duel();
Duel rintar = new Duel();
Duel zersious = new Duel();
Duel balrock = new Duel();
Duel hawkeye = new Duel();
Duel yusef = new Duel();

valon.attack = 6;
valon.defense = 0;
valon.health = 19;

rintar.attack = 8;
rintar.defense = 1;
rintar.health = 16;

zersious.attack = 5;
zersious.defense = 2;
zersious.health = 18;

balrock.attack = 10;
balrock.defense =0;
balrock.health = 15;

hawkeye.attack = 7;
hawkeye.defense = 1;
hawkeye.health = 17;

yusef.attack = 13;
yusef.defense = 2;
yusef.health = 10;


System.out.println("Choose your HERO");
System.out.println("Press 1 for the Mage Lord Valon Press 2 for the Warrior Rintar");
System.out.println("Attack 6 Attack 8");
System.out.println("Defense 0 Defense 1");
System.out.println("Health 19 Health 16");
System.out.println("");
System.out.println("");
System.out.println("Press 3 for the Paladin Prince Zersious Press 4 for the Orc Balrock");
System.out.println("Attack 5 Attack 10");
System.out.println("Defense 2 Defense 0");
System.out.println("Health 18 Health 15");   
System.out.println("");
System.out.println("");
System.out.println("Press 5 for the Elf Hawkeye Press 6 for the Dragon Summoner Yusef");
System.out.println("Attack 7 Attack 13");
System.out.println("Defense 1 Defense 2");
System.out.println("Health 17 Health 10");
hero = input.nextInt();
if(hero == 1){System.out.println("You have chosen Lord Valon!");
for(hero = 1;;){
System.out.println("Your battle is against....");
System.out.println("");
match = 1+battle.nextInt(5);
if(match == 1){
System.out.println("Rintar!");
System.out.println("");
valon.attack1 = 8;
valon.defense1 = 1;
valon.health1 = 16;
valon.calculateWinner();
}else if(match == 2){
System.out.println("Prince Zersious!");
System.out.println("");
valon.attack1 = 5;
valon.defense1 = 2;
valon.health1 = 18;
valon.calculateWinner();
}else if(match == 3){
System.out.println("Balrock!");
System.out.println("");
valon.attack1 = 10;
valon.defense1 = 0;
valon.health1 = 15;
valon.calculateWinner();
}else if(match == 4){
System.out.println("Hawkeye!");
System.out.println("");
valon.attack1 = 7;
valon.defense1 = 1;
valon.health1 = 17;
valon.calculateWinner();
}else if(match == 5){
System.out.println("Yusef!");
System.out.println("");
valon.attack1 = 13;
valon.defense1 = 2;
valon.health1 = 10;
valon.calculateWinner();}
System.out.println("");
System.out.println("Fight again?");
System.out.println("1 for Yes");
System.out.println("2 for No");
restart = input.nextInt();
if(restart == 1){
System.out.println("");
}else if(restart == 2){
System.out.println("Thank you for playing!");
break;}

Add a comment
Know the answer?
Add Answer to:
Question 1. (Magician.java, Healer.java, Fighter.java, HeroTester.java) Consider the abstract hero class and the three subclasses shown...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Problem 5: Monster Factory (10 points) (Game Dev) Create a Monster class that maintains a count...

    Problem 5: Monster Factory (10 points) (Game Dev) Create a Monster class that maintains a count of all monsters instantiated and includes a static method that generates a new random monster object. In software engineering, a method that generates new instances of classes based on configuration information is called the Factory pattern. UML Class Diagram: Monster - name: String - health: int - strength: int - xp: int + spawn(type:String): Monster + constructor (name: String, health: int, strength: int, xp:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT