|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ITollBooth
Objects implementing ITollBooth are used to collect tolls from passing vehicles on a highway.
The toll assessed is based on the weight of the vehicle, which is provided to the object via the arrival
method:
Weight Toll 1-5,000 $0.35 5,000-25,000 $0.50 25,000+ $1.50
Please see the package description for a more in-depth discussion of using this interface.
Method Summary | |
---|---|
void |
addView(IView aView)
Add a view (graphical user interface) to the meter. |
void |
arrival(int weight)
A vehicle with the given weight has arrived at the toll booth. |
void |
collectCoin(double value)
Collect a coin in payment for the toll. |
void |
departure()
A vehicle has departed from the toll booth. |
double |
getAmountOwed()
Get the amount still owed for the current vehicle's toll. |
double |
getTotalCollected()
Get the total amount collected in tolls. |
int |
getTotalVehicles()
Get the total number of vehicles that have passed. |
boolean |
okToLiftGate()
Determine whether enough has been paid to lift the gate. |
Method Detail |
---|
void arrival(int weight)
weight
- The weight of the vehicle arriving at the toll booth.void departure()
double getAmountOwed()
double getTotalCollected()
int getTotalVehicles()
void collectCoin(double value)
value
- The value of the coin just collected from the driver of the vehicle.boolean okToLiftGate()
void addView(IView aView)
updateView
method must be called each time the meter's state changes.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |