horrific.java

来自「Java Classic Examples是我买的两本书:《JAVA经典实例》和」· Java 代码 · 共 28 行

JAVA
28
字号
// Try out observers
import java.util.*;

public class Horrific
{
  public static void main(String[] args)
  {
    JekyllAndHyde man = new JekyllAndHyde();  // Create Dr. Jekyll
    
    Observer[] crowd = {
                        new Person("Officer","What's all this then?"),
                        new Person("Eileen Backwards", 
                                  "Oh, no, it's horrible - those teeth!"),
                        new Person("Phil McCavity",
                              "I'm your local dentist - here's my card."),
                        new Person("Slim Sagebrush",
                                    "What in tarnation's goin' on here?"),
                        new Person("Freaky Weirdo",
                          "Real cool, man. Where can I get that stuff?")};

    // Add the observers
    for(int i = 0; i < crowd.length; i++)
      man.addObserver(crowd[i]);

    man.drinkPotion();                 // Dr. Jekyll drinks up
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?