|
|||||||||
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 ITollBooth
public int getTotalVehicles()
getTotalVehicles
in interface ITollBooth
public void arrival(int weight)
arrival
in interface ITollBooth
weight
- The weight of the vehicle arriving at the toll booth.public void departure()
departure
in interface ITollBooth
public void collectCoin(double value)
collectCoin
in interface ITollBooth
value
- The value of the coin just collected from the driver of the vehicle.public double getAmountOwed()
getAmountOwed
in interface ITollBooth
public boolean okToLiftGate()
okToLiftGate
in interface ITollBooth
public void addView(IView aView)
addView
in interface ITollBooth
aView
- 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 |