Class TollLane

java.lang.Object
  extended by TollLane

public class TollLane
extends Object

This class simulates a toll road that lets people drive their cars through if they pay some money, but then flags them as violators if they don't pay enough!

Version:
2008.02.18
Author:
YT Sun

Constructor Summary
TollLane()
          This method is the public constructor for the TollLane class.
 
Method Summary
 int getCars()
          This method returns the total number of cars that entered the toll lane.
 double getCash()
          This method returns the total amount of cash remaining.
 int getViolators()
          This method returns the total number of cars violators who entered the toll lane.
 void letCarPass(double amount)
          This method lets cars pass on payment of a fee (of their choosing, apparently).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TollLane

public TollLane()
This method is the public constructor for the TollLane class. All non-static class variables (car & violator counts, cash) are initialized to zero (0).

Method Detail

getCars

public int getCars()
This method returns the total number of cars that entered the toll lane.

Returns:
total car count

getCash

public double getCash()
This method returns the total amount of cash remaining.

Returns:
the current balance

getViolators

public int getViolators()
This method returns the total number of cars violators who entered the toll lane.

Returns:
total violator count

letCarPass

public void letCarPass(double amount)
This method lets cars pass on payment of a fee (of their choosing, apparently). Cars who fail to pay the full toll shall be flagged and added to the running count of violators.

Parameters:
amount - the amount paid by the currently passing car