COMP2247 - Algorithms and Data Structures

Syllabus Software Installation Assignments Tests
Lectures and Labs
**Back to Full Menu**

OOP - Aggregation Delivery Program
Address.java
Person.java
MyDate.java
Parcel.java
DeliveryClient.java
Course Program
Book.java
Instructor.java
Student.java
MyDate.java
Course.java
CourseClient.java
Parking Ticket Program
Car.java
Officer.java
ParkingMeter.java
MyDate.java
Ticket.java
ParkingTicketClient.java




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:

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

Source Code

Car class



Officer class



ParkingMeter class



MyDate class (package jym.edu.rctc.parkingticketproject;)



Ticket class



Client program



Sample Run



Video