Source of TestJekyllAndHyde.java


  1: //TestJekyllAndHyde.java

  3: import java.util.Observer;

  5: public class TestJekyllAndHyde
  6: {
  7:     public static void main(String[] args)
  8:     {
  9:         //Create Dr. Jekyll
 10:         JekyllAndHyde man = new JekyllAndHyde();
 11:     
 12:         //Establish a "crowd of observers"
 13:         Observer[] crowd =
 14:         {
 15:             new Person("Officer",
 16:                        "What's all this then?"),
 17:             new Person("Phil McCavity",
 18:                        "I'm your local dentist -- here's my card."),
 19:             new Person("Eileen Backwards", 
 20:                        "Oh, no, it's horrible -- those teeth!"),
 21:             new Person("Slim Sagebrush",
 22:                        "What in tarnation's goin' on here?"),
 23:             new Person("Freaky Weirdo",
 24:                        "Real cool, man. Where can I get that stuff?")
 25:         };

 27:         //Make each crowd member an observer of "the man"
 28:         for(int i=0; i<crowd.length; i++)
 29:             man.addObserver(crowd[i]);

 31:         //Dr. Jekyll drinks up, and ...
 32:         man.drinkPotion();
 33:   }
 34: }