public class Monster { protected String clanAffiliation; protected int ferocity; protected int defense; protected int magic; protected int treasure; protected int health; public Monster(String clanAffiliation, int ferocity, int defense, int magic) { this.clanAffiliation = clanAffiliation; this.ferocity = ferocity; this.defense = defense; this.magic = magic; this.treasure = 0; this.health = 100; } public String getClanAffiliation() { return clanAffiliation; } public int getFerocity() { return ferocity; } public int getDefense() { return defense; } public int getMagic() { return magic; } public int getTreasure() { return treasure; } public int getHealth() { return health; } public void addTreasure(int treasure) { if (health > 0) { this.treasure += treasure; } } public void subtractTreasure(int treasure) { if (health > 0) { this.treasure -= treasure; if (this.treasure < 0) { this.treasure = 0; } } } public void addHealth(int amount) { if (health > 0) { health += amount; } } public void subtractHealth(int amount) { if (health > 0) { health -= amount; if (health < 0) { health = 0; } } } public boolean isAlive() { return health > 0; } public double getBattleScore() { if (health <= 0) { return 0; } return (ferocity + defense + magic) / 3.0; } public abstract void attack(Monster opponent); public abstract void defend(double opponentBattleScore); @Override public String toString() { return "Monster{" + "clanAffiliation='" + clanAffiliation + ''' + ", ferocity=" + ferocity + ", defense=" + defense + ", magic=" + magic + ", treasure=" + treasure + ", health=" + health + '}'; } } public class Orc extends Monster { private OrcCommander commander; public Orc(String clan, int ferocity, int defense, int magic, int treasure, int health) { super(clan, ferocity, defense, magic, treasure, health); } public void setCommander(OrcCommander commander) { this.commander = commander; } public OrcCommander getCommander() { return commander; } public int getLeadership() { if (this instanceof Warlord) { Warlord warlord = (Warlord) this; return warlord.getLeadership(); } return 0; } public int getInfantryCount() { if (this instanceof Warlord) { Warlord warlord = (Warlord) this; return warlord.getInfantryCount(); } return 0; } public void setInfantry(Warlord warlord) { if (this instanceof Infantry) { Infantry infantry = (Infantry) this; infantry.setCommander(warlord); } } @Override public void attack(Monster opponent) { int attackScore = calculateAttackScore(); int defenseScore = opponent.calculateDefenseScore(); int damage = Math.max(attackScore - defenseScore, 0); opponent.takeDamage(damage); } } public class Warlord extends Orc { private int leadershipRating; private Infantry[] infantry; public Warlord(String name, int ferocity, int defense, int magic, int leadershipRating) { super(name, ferocity, defense, magic); this.leadershipRating = leadershipRating; this.infantry = new Infantry[5]; } public int getLeadershipRating() { return leadershipRating; } public void setLeade.