next up previous
Next: Changing the current speed Up: Your job in this Previous: Your job in this

Controlling the accelerator

One of your tasks is to write the bodies of methods checkTurnOff and checkTurnOn, which should turn the accelerator off and on depending on the desired speed and the current speed.

There is one problem here. If you program the accelerator to turn on and off based simply on whether the desired speed is less than or greater than the current speed, then the accelerator may switch on or off at almost every single clock tick when the desired and current speeds are almost equal. You don't want your accelerator doing that. So, you must program in something that doesn't allow this to happen --how you do it is up to you.

[You could save this little problem for last; first program in the obvious; then, when the program is all checked out except for this problem, fix this problem.]



Claire Cardie
1998-11-11