CSE110 Spring 2001

Homework #5 Hints


  1. The basic interface to this undersea simulator requires a while loop with a switch case statement (for the instructions) inside. The proper execution of this program also requires some means of recording the status of the octupus (i.e. whether Ringo is holding it, whether it is dazed from being thrown, etc). You can use a few boolean variables to record this information. Make sure to check it at every turn to see if the octopus wriggles free from Ringo's grasp or recovers from its dazed stupor, etc.
  2. An easy solution for this problem is to simply add another switch case within the `g' and `t' cases of the main switch statement for the users' commands. The new switch case can specify different behavior for the different locations.
  3. Here it is necessary to separate the influence of the current location from the influence of the octopus (whether or not it is harassing Ringo) on the result of any move. Since the state of the octopus (held, thrown, etc.) cannot be passed to the function, the octopus' constraints on Ringo's movement should be checked outside the Move function, and only if movement is allowed should the function be called.