/* MuppetMonster.java example code AC Chapin */ package cis214.pkg11inheritance.Monsters; /** * class representing a Muppet Monster **/ public class MuppetMonster extends Monster { private String mySong; // instance var for this class not in Monster /** * default constructor for MuppetMonster **/ public MuppetMonster() { super(); teeth = 0; // muppets don't have teeth mySong = "La la la la la"; } /** * accessor for mySong **/ public String getMySong() { return mySong; } /** * mutator for mySong **/ public void setMySong(String val) { mySong = val; } /** * MuppetMonsters eat cookies * overrides eat from Monster **/ public void eat() { System.out.println("C is for cookie, and cookie is for me!"); } /** * MuppetMonsters can sing **/ public void sing() { System.out.println("I sing " + getMySong()); } /** * MuppetMonsters don't roar **/ public void roar() { // do nothing } /** * MuppetMonsters don't fight!! **/ public void fight(Monster other) { System.out.println(other + " may fight with " + this + ", but nice MuppetMonsters won't fight back."); } /** * overrides toString from Monster * @return * string representing this MuppetMonster **/ public String toString() { return "muppet monster who likes to sing " + getMySong(); } }