Question: Java please. Use the starter code below to create the RPGcharacter class and its sublcasses. import Characters.RPGCharacter; * PLEASE NOTE: This class will not compile

Java please. Use the starter code below to create the RPGcharacter class and its sublcasses.

Java please. Use the starter code below to create the RPGcharacter classand its sublcasses. import Characters.RPGCharacter; * PLEASE NOTE: This class will notcompile until you create the RPGCharacter class public abstract class Attack {private int cost; private String name; private int damage; private int range;

/** * Creates a new attack object given a the cost (mana/energy),

name, damage and range * @param cost the cost to perform thisattack. It could be mana or energy * @param name the name

import Characters.RPGCharacter; 
* PLEASE NOTE: This class will not compile until you create the RPGCharacter class public abstract class Attack { private int cost; private String name; private int damage; private int range; /** * Creates a new attack object given a the cost (mana/energy), name, damage and range * @param cost the cost to perform this attack. It could be mana or energy * @param name the name of the attack * @param damage how much damage the attack will deal. * @param range the maximum range for attacking another target. Unitless */ public Attack(int cost, String name, int damage, int range) { this.cost = cost; this.name = name; this.damage = damage; this.range = range; } public int getCost(){ return cost; } public int getDamage(){ return damage; } public int getRange(){ return range; } public String getName() { return name; } /** * Method used to interact (deal damage or heal) a target * @param target the RPGCharacter target of the attack * @param attackModifier the attack modifier used to change the attacks damage, for example * @return the amount of damage or healing done with the attack. */ public abstract int interactWithTarget(RPGCharacter target, int attackModifier); @Override public String toString() { return String.format("%s - %s (%d) - Damage: %d", "Attack",name, cost, damage); } }
import Characters.RPGCharacter; public class DamageSpell extends Spell{ /** * Creates a new DamageSpell * @param cost the cost to use the spell. This cost is represented in MANA * @param name the name of the spell * @param damage the amount of damage/heal of the attack * @param range the maximum range (distance) of the spell */ public DamageSpell(int cost, String name, int damage, int range) { super(cost, name, damage, range); } /** * Concrete implementation of the spells interaction with the target to deal damage * * @param target the RPGCharacter target of the attack * @param attackModifier Spells should receive the caster's intellect as a modifier * @return the amount of damage done */ @Override public int interactWithTarget(RPGCharacter target, int attackModifier) { target.takeDamage(getDamage() + attackModifier); return getDamage() + attackModifier; } @Override public String toString() { return String.format("%s - %s (%d) - Damage: %d", "DamageSpell",getName(), getCost(), getDamage()); } }
import Characters.RPGCharacter;
* NOTE: This class will not complie until you have the heal method implemented on RPG character public class HealingSpell extends Spell { /** * Creates a new HealingSpell, that is a spell that heals the target instead of inflicting damage * @param cost the cost to use the spell. This cost is represented in MANA * @param name the name of the spell * @param damage the amount of heal done by the spell * @param range the maximum range (distance) of the spell */ public HealingSpell(int cost, String name, int damage, int range) { super(cost, name, damage, range); } /** * Concrete implementation of the interaction with the target. * Healing spells will call the heal method on the target instead of dealing damage * * @param target the RPGCharacter target of the attack * @param attackModifier Spells should receive the caster's intellect as a modifier * @return The amount of healing done. */ @Override public int interactWithTarget(RPGCharacter target, int attackModifier) { target.heal(getDamage() + attackModifier /2); return getDamage() + attackModifier /2; } @Override public String toString() { return String.format("%s - %s (%d) - Heal: %d", "HealingSpell",getName(), getCost(), getDamage()); } }
import Characters.RPGCharacter;
* NOTE: This class will not compile until the takeDamage method is implemented. public class MeleeAttack extends Attack { /** * Creates a new MeleeAttack * @param cost the cost of the attack as Energy * @param name the name of the attack * @param damage the attack's damage * @param range the maximum range (distance) of the attack */ public MeleeAttack(int cost, String name, int damage, int range) { super(cost, name, damage, range); } /** * Metho used to deal damage to a target using a MeleeAttack. * MeleeAttacks should receive the character's strength as the modifier * * @param target the RPGCharacter target of the attack * @param attackModifier the attack modifier should be the character's strength. * @return the damage dealt with the melee attack. */ public int interactWithTarget(RPGCharacter target, int attackModifier){ target.takeDamage(getDamage() + attackModifier); return getDamage() + attackModifier; } } 
import Characters.RPGCharacter;
 * NOTE: This class depends on the implementation of heal method. public class Resurrection extends HealingSpell { /** * Creates a new Resurrection spell. It does not requires any parameters. * The default cost of the spell is 50. Range is unlimited (set to -1) */ public Resurrection() { super(50, "Resurrection", -1,-1); } 
import Characters.RPGCharacter; 
* PLEASE NOTE: This class will not compile until you create the RPGCharacter class public abstract class Spell extends Attack { /** * Creates a new spell * @param cost the cost to use the spell. This cost is represented in MANA * @param name the name of the spell * @param damage the amount of damage/heal of the attack * @param range the maximum range (distance) of the spell */ public Spell(int cost, String name, int damage, int range) { super(cost, name, damage, range); } /** * See superclass for a description * @param target the RPGCharacter target of the attack * @param attackModifier Spells should receive the caster's intellect as a modifier * @return the ammount of damage or healing done with the spell */ public abstract int interactWithTarget(RPGCharacter target, int attackModifier); } 
 /** * Brings the target back to half of its maximumHP only if the target is dead. * It has no effect on live targets * * @param target the RPGCharacter target of the attack * @param attackModifier Spells should receive the caster's intellect as a modifier * @return the targets current hp if the target was dead. -1 if the target was already alive */ @Override public int interactWithTarget(RPGCharacter target, int attackModifier) { if(target.getCurrentHP()   Attacks: Contain the classes related to attacks in the game. These classes implementation is provided. Study them before starting the assignment. You don't have to edit the code inside this package. Characters: Contain the classes related to our game characters. We will have initially three concrete Characters: Mage, Priest, and Warrior Game: This package has an example code on how to use the Charcaters and Attacks to write a small turn-based duel of two game characters. You don't have to edit this code. You can run it once you have done the assignment. You can also study it to understand a bit more of the idea of using abstract types and polymorphism. RPGCharacter -name: String maxHP: int -position: Point #currentHP: int #intellect: int #strenght: int #attackList: ArrayList

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!