Details:
Create a new project in eclipse as a before. Name this one again using
your first initial and last name and then Lab3. So mine would be
jsantoreLab3
Now add a new class to your project in eclipse. Call this class GameTester
Put the following code into the GameTester class:
========================the class code is below=====================
import java.util.Scanner;
public class GameTester {
public GameTester() {
}
public static void main (String[] args){
Scanner reader = new Scanner (System.in);
// GameEnemy badGuy = new GameEnemy(100, 2000L);
System.out.print("What do you want the badGuy's armor to be (choose a number from 1 to 1000:");
int userValue = reader.nextInt();
// badGuy.setArmor(userValue);
System.out.print("How many hits does the bad Guy take?");
userValue = reader.nextInt();
// badGuy.GetHit(userValue);
System.out.print("How many heals does the badGuy get?");
userValue = reader.nextInt();
// badGuy.getHeals(userValue);
long bgHealth = 0;
// bgHealth = badGuy.getHealth();
System.out.println("The badGuy currently has "+ bgHealth + " health");
}
}
====================the class code is above=================
you will find several lines commented out, you will want to remove the
comments on the lines that call methods from the GameEnemy class after
you implement the GameEnemy class.
Now add a second new class to your project. In this class, implement the class defined in the UML diagram below:
The methods in this class must behave as follows
- The GameEnemy Constructor should use its parameters to
initialize the properties initArmor -> armor and initHealth
-> health respectively.
- The setArmor method should change the current value of armor to what ever is passed in.
- The getHealth method should return the current value of health.
- The getHeals method should multiply whatever the number
parameter is by 50 and update the health property by adding this newly
calculate value to the current health.
- The GetHit method should
- multiply the number of hits by 150 and store that is a variable - lets call it damage.
- devide the current value of armor by 1000 and store that in a double variable. lets call it mitigation.
- multiply the damage by the mitigation and reduce the health property by the result.
now uncomment the commented lines of code in the StudentTester
class and compile and test your code. For your reference the lines that
you need to remove the // from the beginning are:
// GameEnemy badGuy = new GameEnemy(100, 2000L);
// badGuy.setArmor(userValue);
-
// badGuy.GetHit(userValue);
// badGuy.getHeals(userValue);
// bgHealth = badGuy.getHealth();
Submitting:
again zip up your project folder and submit it to me by email.
Make sure that your submitted zip file
contains your first initial and last name as part of the zip file name.