1 10 11 15 package foo.bar; 16 17 import org.picocontainer.Startable; 18 19 20 public class Zap implements Startable { 21 private final String hello; 22 private String toString = "Not started"; 23 private boolean started = false; 24 25 public Zap(String hello) { 26 this.hello = hello; 27 } 28 29 public void start() { 30 if(started) throw new IllegalStateException ("Already started"); 31 toString = hello + " Started"; 32 System.out.println(toString() + hashCode()); 33 started = true; 34 } 35 36 public void stop() { 37 if(!started) throw new IllegalStateException ("Not started"); 38 toString = hello + " Stopped"; 39 System.out.println(toString() + hashCode()); 40 started = false; 41 } 42 43 public String toString() { 44 return toString; 45 } 46 } | Popular Tags |