/* Author: James Tam Version: March 4, 2021 Learning objective: * How abstract classes can serve as a design template to specify actual behavior that needs to be implemented by non-abstract child classes (via abstract methods such as 'workout'). * How behavior that is common to all instances of a class and its child classes can be implemented as a default (non abstract methods such as 'rest'). * Retrieving the name of a class at runtime. */ public abstract class TheoreticalPerson implements DesignPerson { private int energy; public TheoreticalPerson() { changeEnergy(DEFAULT_ENERGY); } public TheoreticalPerson(int energy) { changeEnergy(energy); } public void rest() { energy = energy + DEFAULT_ENERGY; } public void changeEnergy(int amount) { energy = energy + amount; } public String toString() { //Object.getClass(): class type of object at runtime. String s = "Class type " + getClass() + " energy=" + energy; return(s); } public abstract void workout(); }