edu.colorado.simulations
Class Throttle

java.lang.Object
  extended by edu.colorado.simulations.Throttle

public class Throttle
extends java.lang.Object

A Throttle object simulates a throttle that is controlling fuel flow.

See Also:
Java Source Code for this class (www.cs.colorado.edu/~main/edu/colorado/simulations/Throttle.java)

Constructor Summary
Throttle(int size)
          Construct a Throttle with a specified number of "on positions."
 
Method Summary
 double getFlow()
          Get the current flow of this Throttle.
 boolean isOn()
          Check whether this Throttle is on.
 void shift(int amount)
          Move this Throttle's position up or down.
 void shutoff()
          Turn off this Throttle.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Throttle

public Throttle(int size)
Construct a Throttle with a specified number of "on positions."

Parameters:
size - the number of "on positions" for this new Throttle
Precondition:
size > 0.
Postcondition:
This Throttle has been initialized with the specified number of "on positions" above the shutoff position, and it is currently shut off.
Throws:
java.lang.IllegalArgumentException - Indicates that size is not positive.
Method Detail

getFlow

public double getFlow()
Get the current flow of this Throttle.

Parameters:
- - none
Returns:
the current flow rate (always in the range [0.0 ... 1.0] ) as a proportion of the maximum flow

isOn

public boolean isOn()
Check whether this Throttle is on.

Parameters:
- - none
Returns:
If this Throttle's flow is above zero, then the return value is true; otherwise the return value is false.

shift

public void shift(int amount)
Move this Throttle's position up or down.

Parameters:
amount - the amount to move the position up or down (a positive amount moves the position up, a negative amount moves it down)
Postcondition:
This Throttle's position has been moved by the specified amount. If the result is more than the topmost position, then the position stays at the topmost position. If the result is less than the zero position, then the position stays at the zero position.

shutoff

public void shutoff()
Turn off this Throttle.

Parameters:
- - none
Postcondition:
This Throttle has been turned off.