CSCI 250 (GOLDWEBER)
Spring 08: 2/4/08
Extra-Credit Project 1: Master Locks
Design and implement a class that can be used in a program that simulates a combination lock. The lock has a circular knob, with the numbers 0 through 39 marked on the edge, and it has a three-number combination, which we will call x, y, and z. To open the lock, one must turn the knob clockwise at least two entire revolutions, stopping with x at the top; then turn the knob counterclockwise, stopping the second time that y appears at the top; finally turn the knob clockwise again, stopping the next time that z appears at the top. At this point, one may open the lock.
Your Lock class should have a constructor that initializes the three-number combination (use 0, 0, 0 for default arguments). Also provide member functions to:
  1. Alter the lock's combination to a new three-number combination.

  2. Turn the knob in a given direction until a specified number appears at the top.

  3. Close the lock.

  4. Attempt to open the lock.

  5. Inquire the status of the lock (open or locked).

  6. Report on what number is currently at the top.

A few notes:



File translated from TEX by TTH, version 3.38.
On 3 Feb 2006, 08:53.