Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is all in java using eclipse the hero class and borg class are in the pictures i need to complete option 1 the HeroTester
This is all in java using eclipse the hero class and borg class are in the pictures i need to complete option 1 the HeroTester and write java docs for each of the three subclasses
Time to have a bit of fun. Consider the abstract "hero" class and the three subclasses shown below. Hero -health -name +Hero (name : String) +deal Damage () : int +takeDamage (damage : int) : theal (addllcalth: int) getllealth() : int #getName() : String +isDead() : boolean +LOSLring(): String Magician Fighter Healer -mana: int -strength: int +Magician) +deal Damage() : int +lightning () : int #getMana(); int +addMana (addMana : int): +toString() : String +Fighter() +deal Damage() : int +berserk (): int getStrenght(); int addStrength (addStrength: int) : +tostring() : String - dexterity: int +Healer() theal(); int +get Dexterity : Int +addexterity laddexterity: int) : +toString(): String **NOTE: for the above diagram - the Healer class is accidentally missing the dealDamage(): int method. This method should also be present in the Healer class, it's just missing from the diagram above.** 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. 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 JavaDocs for each of the three subclasses (not the tester). Option 1: (for almost full tester marks) Write a hard-coded tester that does the following: Create an array of three heroes (one of each subclass type) Show that each of the methods works for each hero Create at least one Borg object and have one of your heroes battle the Borg, show at least a couple of interactions. 1 package assignment3; 31 4 5 public class Borg { 6 7 private int health; 8 90 /** 10 * Constructor 11 */ 120 public Borg() { 13 this.health = (int) (Math.random()*15)+45; 14 } 15 160 /** 17 * Accessor for health. 18 * @return Borg's current health. 19 */ 20 public int getHealth() { return health; } 21 22 230 /** 24 * Borg takes damage from enemy. 25 * @param damage how much damage to take. 26 276 public void takeDamage (int damage) { 28 this.health -= damage; 29 if(healthStep 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