|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectbecker.xtras.tollBooth.SampleTollBooth
public class SampleTollBooth
A sample class implementing the ITollBooth interface. It collects tolls, provides totals, and determines
when it is appropriate to lift the toll gate.
Please see the package description for a more in-depth discussion of using this class.
| Constructor Summary | |
|---|---|
SampleTollBooth()
|
|
| Method Summary | |
|---|---|
void |
addView(IView aView)
Add a new view that is observing this object. |
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. |
static void |
main(String[] args)
Test the class. |
boolean |
okToLiftGate()
Determine whether enough has been paid to lift the gate. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SampleTollBooth()
| Method Detail |
|---|
public double getTotalCollected()
getTotalCollected in interface ITollBoothpublic int getTotalVehicles()
getTotalVehicles in interface ITollBoothpublic void arrival(int weight)
arrival in interface ITollBoothweight - The weight of the vehicle arriving at the toll booth.public void departure()
departure in interface ITollBoothpublic void collectCoin(double value)
collectCoin in interface ITollBoothvalue - The value of the coin just collected from the driver of the vehicle.public double getAmountOwed()
getAmountOwed in interface ITollBoothpublic boolean okToLiftGate()
okToLiftGate in interface ITollBoothpublic void addView(IView aView)
addView in interface ITollBoothaView - The view to add.public static void main(String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||