Skip to content

Latest commit

 

History

History
152 lines (105 loc) · 4.34 KB

File metadata and controls

152 lines (105 loc) · 4.34 KB

BBM104 – Programming Assignment 3 (Fall 2023)

Academic Course Management System (ACMS)

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.


Goals

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

Features / Commands

The program supports these operations:

1) Student operations

  • AddStudent: create a new student record (unique ID)
  • RemoveStudent: remove a student by ID
  • ListStudents: print all students ordered by name

2) Enrollment operations

  • CreateEnrollment: create a new course enrollment for an existing student (unique enrollment ID)

3) Assessment operations

  • AddAssessment: add an assessment (and task components) to a specific enrollment
  • TotalFee: list the assessments in the enrollment and calculate total fee

Data Model Summary

Student attributes

A student record includes:

  • student id (unique)
  • student surname
  • student name
  • student address
  • student phone number

Enrollments

Each enrollment includes:

  • enrollment id (unique)
  • student id
  • one or more assessments

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.


Persistence Files

student.txt format

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

courseEnrollment.txt format

Blocks of data:

<enrollmentID>    <studentID>
<assessmentType>    <tasks [1-4]>
...

Notes:

  • Entries ordered by ID
  • After adding/removing tasks, changes are written back

Input File Format (input.txt)

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 File Format (output.txt)

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

Design Patterns

Decorator Pattern

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

DAO Layer

Persistence operations are implemented via a DAO interface.

Core methods:

  • getByID(int ID)
  • deleteByID(int ID)
  • add(Object object)
  • getALL()