ANSWER TO EXERCISE 1 | |
Change the mushroom's after rule to: after [; Take: if (self hasnt general) { give self general; "You pick the mushroom, neatly cleaving its thin stalk."; } "You pick up the slowly-disintegrating mushroom."; Drop: "The mushroom drops to the ground, battered slightly."; ],As mentioned above, general is a general-purpose attribute, free for the designer to use. The 'neatly cleaving' message can only happen once, because after that the mushroom object must have general. Note that the mushroom is allowed to call itself self instead of mushroom. |