This repo contains my solution for BBM104: Introduction to Programming Laboratory II – Programming Assignment 3, focused on Inheritance & Polymorphism, plus the Decorator and DAO design patterns. The application has been dockerized to ensure easy setup and execution across different environments. With Docker installed, the project can be built and run without dealing with local dependency or configuration issues. For detailed instructions on how to build and run the application using Docker, please refer to the README-DOCKER file.
Build a simple Academic Course Management System (ACMS) in Java that:
- Reads commands from an input file and writes results to output.txt
- Stores persistent data in text files (student.txt and courseEnrollment.txt) and updates them based on commands
- Uses:
- Inheritance & polymorphism as core OOP principles
- Decorator pattern for adding assessment tasks dynamically
- DAO (Data Access Object) layer for persistence operations
The program supports these operations:
- AddStudent: create a new student record (unique ID)
- RemoveStudent: remove a student by ID
- ListStudents: print all students ordered by name
- CreateEnrollment: create a new course enrollment for an existing student (unique enrollment ID)
- AddAssessment: add an assessment (and task components) to a specific enrollment
- TotalFee: list the assessments in the enrollment and calculate total fee
A student record includes:
- student id (unique)
- student surname
- student name
- student address
- student phone number
Each enrollment includes:
- enrollment id (unique)
- student id
- one or more assessments
There are two assessment types:
- Essay-based Assessment — base fee 10 credits
- Multiple Choice Assessment — base fee 15 credits
Each assessment can be decorated with additional tasks/components:
- LiteratureReview — 15 credits
- Analysis — 10 credits
- QuestionSet — 7 credits
- AdditionalTasks — 5 credits
These tasks demonstrate inheritance/polymorphism and runtime behavior composition via the Decorator pattern.
Each line:
<studentID> <studentName> <studentSurname> <phone number> <address...>
Notes:
- Entries ordered by ID
- Address may contain multiple words
- All add/remove changes are reflected in the file
Blocks of data:
<enrollmentID> <studentID>
<assessmentType> <tasks [1-4]>
...
Notes:
- Entries ordered by ID
- After adding/removing tasks, changes are written back
Commands are space-separated:
- AddStudent <address...>
- RemoveStudent
- CreateEnrollment
- AddAssessment
- TotalFee
- ListStudents
Task count may vary. Implementations typically model “assessment base + decorators” as the stack, with tasks added via decorators.
Output lines include:
- Student added
- Student removed
- Course Enrollment created
- assessment added to enrollment
- TotalFee for enrollment
- <task...> $
- Total: $
- Student List: followed by the listed students
Used for adding tasks to an assessment at runtime.
Example logic:
assessment.addtask(new Analysis(new QuestionSet(new AdditionalTasks())));
assessment.printtasks(); // AdditionalTasks, QuestionSet, Analysis
assessment.fee(); // assessment + tasks total
Key points:
- Decorators must be nestable
- printtasks() prints tasks in correct order
- fee() sums base and task fees
Persistence operations are implemented via a DAO interface.
Core methods:
- getByID(int ID)
- deleteByID(int ID)
- add(Object object)
- getALL()