question archive This is a pokemon style game   The most basic part of the Pokemon game is the Moves

This is a pokemon style game   The most basic part of the Pokemon game is the Moves

Subject:Computer SciencePrice:9.82 Bought3

This is a pokemon style game

 

The most basic part of the Pokemon game is the Moves.

During a Pokemon Battle, Pokemon can use Moves on each other to do damage to their opponents. A Move has a name as well as the amount of damage it can do. The maximum damage a Move can do is MAX_DAMAGE, if the Move constructor is called with a damage greater than MAX_DAMAGE, you should set the damage for that Move to be MAX_DAMAGE.

For example, Squirtle may use Water Gun on Charmander, doing 15 damage.

The job is to write the Move Class. You should write the Constructor, as well as the following methods:

// Returns the name of the Move
public String getName()

// Returns how much damage this Move does
public int getDamage()

// Returns a String representation of this Move
// Example: "Water Gun (15 Damage)"
public String toString()

 

 

WRITE USING THE BELOW CODE AS A STARTING TEMPLATE. ONLY ADD TO THE BELOW TEMPLATE. 

 

MoveTester.Java

public class MoveTester extends ConsoleProgram
{
    public void run()
    {
        // Test out the Move class here!
    }
}

 

Move.java

public class Move
{
    // Private constants
    private static final int MAX_DAMAGE = 25;
    
    // Write the implementation of the Move class here
}

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

Adding the code for Move.java.  I don't have the ConsoleProgram.java class so can't provide the MoveTester.java. 

Step-by-step explanation

public class Move {
   private static final int MAX_DAMAGE = 25;
   private String name;
   private int damage;

   public Move(String name, int damage) {
      this.name = name;
      this.damage = Math.min(damage, MAX_DAMAGE);
   }

   // Returns the name of the Move
   public String getName() {
      return name;
   }

   // Returns how much damage this Move does
   public int getDamage() {
      return damage;
   }

   // Returns a String representation of this Move
   // Example: "Water Gun (15 Damage)"
   public String toString() {
      return getName() + " (" + getDamage() + " Damage)";
   }
}