Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hero.java package question1; /** * An abstract class to describe a basic hero. * @author Aaron * */ public abstract class Hero { private String

image text in transcribed

image text in transcribed

image text in transcribed

Hero.java

package question1;

/** * An abstract class to describe a basic hero. * @author Aaron * */

public abstract class Hero { private String name; private int health; /** * Argumented constructor * @param name Hero's name. */ public Hero(String name){ if(name == "" || name.length() == 0) this.name = "anonymous"; else this.name = name; this.health = 100; } /** * Accessor for health. * @return Hero's current health. */ public int getHealth() { return health; } /** * Accessor for Name * @return Hero's name. */ public String getName() { return name; } /** * Add to the hero's health. * @param addHealth how much health to add. */ public void heal(int addHealth){ this.health += addHealth; } /** * Hero takes damage from enemy. * @param damage how much damage to take. */ public void takeDamage(int damage){ this.health -= damage; if(health

}

Goblin.java

package question1;

/** * A class to describe a basic villan. * @author Aaron * */

public class Goblin {

private int health; /** * Constructor */ public Goblin(){ this.health = (int)(Math.random()*15)+45; } /** * Accessor for health. * @return Goblin's current health. */ public int getHealth() { return health; } /** * Goblin takes damage from enemy. * @param damage how much damage to take. */ public void takeDamage(int damage){ this.health -= damage; if(health

}

Question l. (Magician,java, Healer java, Fighter-java, HeroTester java) Consider the abstract hero class and the three subclasses shown below Hero LAt Magician 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 e 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 Iround to integer values). Using Berserk costs one Strength point. When a fighter is constructed they have 3 strength points the dealDamagel) method for the fighter does between 7 and 10 points of damage Magician The magician has an extra data field called Mana and a methad called Lightning. When the magician calls Lightning the damage they inflict is quadruple what it would have been otherwise. Call the existing dealDamage magician has 4 Mana points to start with the dealDamage() method for the magician does between 4 and 6 points of damage function and quadruple the value before dealing it to the enemy. Using Lightning costs 1 Mana point and a 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 dealDamagef) method for the Healer does between 3 and 5 points of damage Question l. (Magician,java, Healer java, Fighter-java, HeroTester java) Consider the abstract hero class and the three subclasses shown below Hero LAt Magician 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 e 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 Iround to integer values). Using Berserk costs one Strength point. When a fighter is constructed they have 3 strength points the dealDamagel) method for the fighter does between 7 and 10 points of damage Magician The magician has an extra data field called Mana and a methad called Lightning. When the magician calls Lightning the damage they inflict is quadruple what it would have been otherwise. Call the existing dealDamage magician has 4 Mana points to start with the dealDamage() method for the magician does between 4 and 6 points of damage function and quadruple the value before dealing it to the enemy. Using Lightning costs 1 Mana point and a 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 dealDamagef) method for the Healer does between 3 and 5 points of damage

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

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions

Question

Give a brief defi ni tion of the terms population and sample.

Answered: 1 week ago