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




Course Program


Description

This program uses OOP aggregation (composition) concept to design classes to represent course object.

Each course object includes data members representing the course number, course title, credit hours, location, instructor, book, starting date, ending date, and student list.

The program defines Book, Instructor, MyDate, Student, and Course classes.

The Course class incorporates the aggregation technique to includes the objects of Book, Instructor, Student, and MyDate as data members.


This problem was originally presented as an example in Starting out with Java 4th Edition book (page 515).
Authors: Tony Gaddis and Godfrey Muganda
The requirements are expanded to meet our purpose.


Associated Concepts:

OOP - Aggregation

Algorithm:

Class diagrams:





Client program:

Call addCourse method to create a Course object

Use the Course object reference to add the starting and ending dates

Use the Course object reference to add the Student list

Use the Course object reference to add the Book

Use the Course object reference to add the Instructor

Print the result

Source Code

Book class



Instructor class



Student class



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



Course class



Client program

It includes the code to create the Course object and add the starting date, the ending date, and the student list.

You can complete the program by writing the code to add Book and Instructor objects to the Course object.



Sample Run



Video