CS 372 Throttle Class
The simple throttle that we have in mind is a lever that can be moved to control fuel flow. The throttle we have in mind has a single shutoff point (where there is no fuel flow) and a sequence of six on positions where fuel is flowing at progressively higher rates. At the topmost position, the fuel flow is fully on.lever. For example, with six possible positions, and the lever in the fourth position, the fuel flows at 4/6 of its maximum rate.
One function provided with the class permits a program to initialize a throttle to its shutoff position. Once the throttle has been initialized, there is another function to shift the throttle lever by a given amount.
We also have two functions to examine the status of a throttle. The first of these functions returns the amount of fuel currently flowing, expressed as a proportion of the maximum flow. For example, this function will return approximately 0.667 when the six-position throttle is in its fourth position. The other function returns a true-or-false value, telling whether the throttle is currently on (that is, whether the lever is above the zero position).
The throttle must have four positions:
1. A function to set a throttle to its shutoff position.
2. A function to shift a throttle’s position by a given amount.
3. A function that returns the fuel flow, expressed as a proportion of the maximum flow.
4. A function to tell us whether the throttle is currently on.