Parking Ticket Program
Description
This program uses OOP aggregation (composition) concept to design classes to represent Parking Ticket object.Each ticket object includes data members representing the illegal parked minutes, fine, car information, officer information, and date information.
The program defines Car, Officer, MyDate, ParkingMeter, and Ticket classes.
The Ticket class incorporates the aggregation technique to includes the objects of Car, Officer, and MyDate as data members.
This problem was originally presented as an exercise in Starting out with Java 4th Edition book.
Exercise 8 in Chapter 8 (page 554). Authors: Tony Gaddis and Godfrey Muganda
The requirements are expanded to meet our purpose.
Associated Concepts:
OOP - Aggregation
Algorithm:
Class diagrams:
Client program:
Client program:
Create objects of Car, Officer, ParkingMeter, and MyDate
Use the Officer object reference to invoke the patrol method which will check the parking meter and purchased minutes by the parked car.
The patrol method then returns a Ticket object.
Print the result
Use the Officer object reference to invoke the patrol method which will check the parking meter and purchased minutes by the parked car.
The patrol method then returns a Ticket object.
Print the result
Source Code
Car classOfficer class
ParkingMeter class
MyDate class (package jym.edu.rctc.parkingticketproject;)
Ticket class
Client program