I am doing a project in Java (RPG-Game) and there is a method, called "sleep()", if the hero sleep he can't fight against enemys or others and if he has for example 1 HP after he slept he gets max HP and then he is ready to fight. And my problem is that I need a timer for the sleep method, for example the Hero "Venus" sleeps for 3 Minutes and he can't fight in that time.
My attributes and my method:
public class Superhero {
private String id = UUID.randomUUID().toString();;
private String name;
private int healthPointsMax;
private int healthPointsCurrent;
private int damage;
private int critStrike;
private int critChance;
private String heroRole;
private int experiencePoints;
private String superpowers;
private boolean readyToFight;
private boolean inFight;
private boolean alive;`
and my method:
public void sleep() {
System.out.println("Dein Superheld " + name + " legt sich schlafen.");
System.out.println(name + " hat wieder volle HP, wenn er/sie wach ist.");
setHealthPointsCurrent(getHealthPointsMax());
readyToFight = false;
}