IMS-java/Code/Steiner/simpleGame/src/Enemy.java
2024-11-27 15:00:54 +01:00

18 lines
569 B
Java

public class Enemy extends Character {
private int maxHealth; // Store the original health value
public Enemy(String name, int health, int attackPower) {
super(name, health, attackPower);
this.maxHealth = health; // Initialize maxHealth to the starting health
}
public void resetHealth() {
this.health = maxHealth; // Restore health to its original value
}
@Override
public void displayInfo() {
System.out.printf("Enemy: %s | Health: %d | Attack: %d%n",
name, health, attackPower);
}
}