becker.xtras.tollBooth
Class SampleTollBooth

java.lang.Object
  extended by becker.xtras.tollBooth.SampleTollBooth
All Implemented Interfaces:
ITollBooth

public class SampleTollBooth
extends Object
implements ITollBooth

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.

Author:
Byron Weber Becker

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

SampleTollBooth

public SampleTollBooth()
Method Detail

getTotalCollected

public double getTotalCollected()
Get the total amount collected in tolls.

Specified by:
getTotalCollected in interface ITollBooth

getTotalVehicles

public int getTotalVehicles()
Get the total number of vehicles that have passed.

Specified by:
getTotalVehicles in interface ITollBooth

arrival

public void arrival(int weight)
A vehicle with the given weight has arrived at the toll booth.

Specified by:
arrival in interface ITollBooth
Parameters:
weight - The weight of the vehicle arriving at the toll booth.

departure

public void departure()
A vehicle has departed from the toll booth.

Specified by:
departure in interface ITollBooth

collectCoin

public void collectCoin(double value)
Collect a coin in payment for the toll.

Specified by:
collectCoin in interface ITollBooth
Parameters:
value - The value of the coin just collected from the driver of the vehicle.

getAmountOwed

public double getAmountOwed()
Get the amount still owed for the current vehicle's toll.

Specified by:
getAmountOwed in interface ITollBooth

okToLiftGate

public boolean okToLiftGate()
Determine whether enough has been paid to lift the gate.

Specified by:
okToLiftGate in interface ITollBooth

addView

public void addView(IView aView)
Add a new view that is observing this object.

Specified by:
addView in interface ITollBooth
Parameters:
aView - The view to add.

main

public static void main(String[] args)
Test the class.