Answer:
public class Dragon {
private String name;
private int level;
private boolean canBreatheFire;
public Dragon(String name,int level){
this.name=name;
this.level=level;
if(level>=70) {
this.canBreatheFire=true;
}
}
public String getName() {
return name;
}
public int getLevel() {
return level;
}
public boolean getCanBreatheFire() {
return canBreatheFire;
}
public void attack() {
if(getCanBreatheFire()) {
System.out.println(">>> 999");
}else {
System.out.println("Dragon does not have fire breath.");
}
}
public void gainExperience() {
level += 5;
}
public String toString() {
return "Dragon "+ name + " is at level "+ level;
}
Step-by-step explanation:
The Java program above is a class called Dragon. An object instance of the dragon class has a name and level class variable. The level is used to determine the Boolean value of the canBreathFire class variable. The variables can be retrieved with the getter methods and the level updates by the experience method.