LAB MID Sec B
LAB MID Sec B
You have been hired to develop an application for National Highway Authority (NHA) who
manages its operations on Toll Plaza.
Toll plaza handles two kinds of Vehicles ; LightWeightVehicle and HeavyWeightVehicle. Light
weight vehicle is the one which transports passengers and includes bike and car whereas heavy
weight vehicle includes Truck and it transports luggage. For charging toll tax, NHA is interested
in vehicle title (bike/car/truck) , its tax(Rs), and its Vehicle no. Light Weight Vehicle has an
additional data member Model. Heavy weight vehicle will have an additional data member weight.
If weight exceeds standard weight i.e. 8000KG then an extra Rs. 100/- will be charged.
Note that NHA don't charge tax for ARMY vehicles including car & truck.
Whenever a vehicle reach toll plaza, it will enter in its own lane, pay tax and take system generated
receipt. If it belongs to Army then toll plaza manager will let it pass without any tax charges.
Bike, L1 10
Car, L1 20
Truck, L2 30
You have to implement above requirements in “OOP way”. Following section explains the
structure of classes and function of main class:
There will be total of Six classes; Vehicle, LightWeightVehicle, HeavyWeightVehicle,
TollPlaza, Ticket and Main.
1. Vehicle Class:
a. Find data member(s) yourself from above description.
b. This class will contain an abstract method generateReceipt(). In child classes it will
be implemented in following way that it displays below result:
2. LightWeightVehicle Class:
a. Find data member(s) yourself from above description.
3. HeavyWeightVehicle Class:
a. Find data member(s) yourself from above description.
4. Ticket Class:
a. Ticket Class will store information of Ticket No, Date (Current date & time), Lane
No and ClassType (LightWeightVehicle/HeavyWeightVehicle)
5. Toll Plaza Class:
a. It has two ArrayLists of Vehicle and Ticket as data member; ArrayList<Vehicle>,
ArrayList<Ticket>.
b. Further data members include: Ticket no (Auto generated, unique for every receipt)
which will be copied to Ticket.ticketNo too.
c. addVehicle(Vehicle vehicle ) that takes Vehicle object as argument. Additionally in
this function create an object of Ticket and initialize Ticket variables i.e Lane no, class
name and Date according to the vehicle object that is passed as input argument. Also
assign ticket no and make sure that it should be unique for each vehicle. Now add
vehicle and ticket objects in their respective ArrayList. Call GenerateReceipt()
function in the end of this function.
d. Vehicles which belongs to Army will not be added to the ArrayList. (You are free to
add any additional data member for implementing this point)
e. Two overloaded methods getAllVehicles() that returns an ArrayList of all vehicles
and getAllVehicles(String className) that returns Vehicles of class specified. For
example, if the class specified is Light weight vehicles, this function returns all the
objects from ArrayList which only belongs to Light weight vehicles class.
f. Similar to point (e), we will have 2 overloaded methods getAllVehiclesByTicket() that
returns an ArrayList of all vehicles ticket info and getAllVehiclesByTicket(String
className) that returns Vehicles ticket info of class specified.
We are making ticket arrays just to store complete information so at index 0 of both
arrays, we have info of vehicle 1, on index 1 of both arrays, we have info of vehicle 2
etc.
6. Main Class:
a. Main class displays the following menu on console:
Case 3 (Truck) will have the below output. Please notice that if Truck weight exceeds the limit
of 8000KG then additional tax will be charged and displayed.
7. Realize the relations (Inheritance, Abstraction and Polymorphism). Make use of the best
programming practices learned in the labs. All required classes should have default
constructors and parameterized constructors with a call to super constructor (if any),
overridden toString() method with a call to super toString() (if any) and getters & setters.
The program is already lengthy enough so input from the user is not advised, set the values
of objects using parameterized constructor calls.
NOTE: You should implement all OOP concepts that you have learned in labs, along with that you
should use proper naming conventions and document formatting, all these carry marks
weightage.
Marks distribution
Topic Marks
Vehicle Class + abstract
5+2
method
Light weight vehicle Class +
abstract method 5+3
implementation
Heavy Weight vehicle Class +
abstract method 5+3
implementation
Ticket Class 2
Toll Plaza Class (addVehicle,
getAllVehicles
,getAllVehiclesByTicket (4
3+7+7+3=20
overloaded methods in
total))+Handling Army
vehicles
Main Class 10
Naming convention, code
5
completion, code formatting
Total 60