Text based java game

Hi guys I'm working on a text based java game. The player can kick high and low, punch left and right, acquire health, acuire power, and has a shield that he can turn on for 5 seconds. I came up with the following code:

[code]
public class Fighter
{
private int power;
private int health;

public Fighter()
{
setPower(100);
health = 100;
}

public boolean IsShieldOn()
{
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return true;
}

public void highKick()
{
setPower(- 5);
}

public void lowKick()
{
setPower(- 3);
}

public void leftPunch()
{
setPower(- 3);
}

public void rightPunch()
{
setPower(- 3);
}

public void acquireHealth()
{
setHealth(+ 10);
}

public void acquirePower()
{
setPower(+ 10);
}

public void setHealth(int health) {
this.health = health;
}

public int getHealth() {
return health;
}

public void setPower(int power) {
this.power = power;
}

public int getPower() {
return power;
}
}

[/code]


Any ideas how I can make this code better? I was wondering how I can create a tester class for this also.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories