Comp 151 Project 3

Creating a class

Summary:

You will create your first full class with attributes and methods in this project

Due: Wednesday Feb23rd at 11:59pm


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:

UML diagram for the Game Enemy class which must be implemented

The methods in this class must behave as follows

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:
  1. // GameEnemy badGuy = new GameEnemy(100, 2000L);
  2. // badGuy.setArmor(userValue);
  3.  // badGuy.GetHit(userValue);
  4. // badGuy.getHeals(userValue);
  5. // 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.