Answer to Exercise 10

| ANSWER TO EXERCISE 10
    Object television "portable television set" lounge
      with name "tv" "television" "set" "portable",
           before
           [;  SwitchOn: <<SwitchOn power_button>>;
               SwitchOff: <<SwitchOff power_button>>;
               Examine: <<Examine screen>>;
           ],
      has  transparent;
    Object -> power_button "power button"
      with name "power" "button" "switch",
           after
           [;  SwitchOn, SwitchOff: <<Examine screen>>;
           ],
      has  switchable;
    Object -> screen "television screen"
      with name "screen",
           before
           [;  Examine: if (power_button hasnt on) "The screen is black.";
                   "The screen writhes with a strange Japanese cartoon.";
           ];

Back to the exercise in section 11

Mechanically translated to HTML from third edition as revised 16 May 1997. Copyright © Graham Nelson 1993, 1994, 1995, 1996, 1997: all rights reserved.