On our expressways, our toll ways accept payment in cash or with the use of an ePass.
Cars using cash to pay the toll will always pay the correct fee.
If an ePass does not have enough credits, the remaining balance is collected by the toll lane,
the car is counted as violator, but is still allowed to pass through.

1. Using bluej, create a class called TollLane which implements the ff. methods:
* public void letCarPass (boolean ePass, double ePassBalance, double tollFee)
- allows one car enter the toll lane upon paying:
- epass is true when the car is using an epass to pay.
- ePassBalance represents the amount of credits available on the ePass.
- tollFee represents the amount to be paid.

* public double getCash()
- returns the total amount of cash collected by the toll lane.

* public int getCars()
- returns the total number of cars that have passed through the total lane.

* public int getViolators()
- returns the total number of cars that did not have enough credits.

2. Your program should include Java.doc formatted method comments and leader information.

3. Create a TollPlaza class that test your program.:icon_question:

Edited by __avd: Remove [code] tags.

7 Years
Discussion Span
Last Post by javaAddict

The letCarPass will do what is described. In the class you will have private attributes: cash, cars, violators. These will be returned by the respective get methods.
Whenever the letCarPass method is called depending on the arguments and the description provided you will increase accordingly the above fields: cash, cars, violators

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.