/** * Abstract class with common properties and behavior for Oz citizens * CSE142 HW5 sample solution. HP 3/1/04 */ public abstract class CastMember { // instance variables private int nSkip; // number of skips this cast member has performed /** Construct a new CastMember */ public CastMember() { nSkip = 0; } /** Return the CastMember's name */ public abstract String getName(); /** Return words from a song */ public String sing() { return "Ding! Dong! The witch is dead!"; } /** Return a string with n "skip"s */ public String skip(int n) { if (n <= 0) { return ""; } else { String skips = "skip"; for (int k = 2; k <= n; k++) { skips = skips + " skip"; } nSkip = nSkip + n; return skips; } } /** Return the number of skips */ public int getSkips() { return nSkip; } /** Return this character's saying */ public abstract String getSaying(); }