/** * Acrobat - an implementation of Performer. * CSE 142 Lecture demo, 2/18/04 */ public class Acrobat implements Performer { // instance variables private int totalTimes; // total number of claps and twirls /** * Construct a new Acrobat */ public Acrobat() { totalTimes = 0; } /** * Twirl the specified number of times * @param n number of times to twirl */ public void twirl(int n) { for (int k = 0; k < n; k++) { System.out.println("spin"); } totalTimes = totalTimes + n; } /** * Clap the specified number of times * @param n number of times to clap */ public void clap(int n) { for (int k = 0; k < n; k++) { System.out.println("clap!"); } totalTimes = totalTimes + n; } /** * Report the total number of claps and twirls * @return total number of claps and twirls performed by this Actor */ public int tellCount() { return totalTimes; } /** * Return a String representation of this Performer * @return a String identifying this Performer as an Acrobat */ public String toString() { return "Acrobat who has done " + totalTimes + " things."; } }