The objectives of this question are

  • to introduce subclasses in a case study
  • to apply the various OOP concepts

A training institution has invited your team to build a computerized system to record its courses and students. You have been tasked to develop a prototype based on the user specifications and the design proposed by your team.

A course consists of formal lessons. It has a unique course code, a title, fees and duration. Applied courses are courses that include a practicum in a related industry. Data for some courses is given in Table (1) below: See image.

Courses are offered and scheduled regularly. Data for some course offering is given in Table (2) below: See image.

Your team proposed that each course offering also records the course for the course offering,

Students, both local and international, can enrol in any course, whether applied or otherwise. Students choose a course offering by selecting the course code and start date of the course they wish to enrol in, from the list of the course offerings that are open for enrolment. A course offering is open or close at the discretion of the administrator to facilitate international students. However, the course offering is always made close whenever the vacancy reaches 0.

An international student must apply for a student pass when enrolled in a course where the duration exceeds 4 weeks. A check must be made at enrolment time so that the requirement can be displayed if an international student selects to enrol in such a course.

The enrolment process completes when students make an online payment. All local students pay a fixed 30% non-refundable deposit but international students pay 50% deposit because of their foreign status. However, the additional 20% is refunded if the student pass application is not approved. The team has decided to implement the required deposit percentages as constants.

The course offering will record the list of students who have enrolled in it. At the same time, a single course offering that a student has enrolled in will also be part of the student record.

A student must be successfully registered before enrolling in any course. The following data is recorded during registration: student number, name, date registered and identification number (NRIC for local and passport number for international students). The student pass number, subsequently obtained for international students enrolled in course with duration exceeding 4 weeks, must be recorded before the commencement of the course.

Data for some students is given in Table (3) below: See image.

You are given the following fragment of a class diagram in Figure 1and an extract of the description of the classes for the system follows. See image.

Class Course: This class models a course in the training institution. There are two types of courses: Course and AppliedCourse. Every course has a unique code (String), title (String), fees (double), lessonDuration (int).

Class AppliedCourse: This class is a subclass of Course. It models an applied course in the training institution. In addition to the attributes it inherits from the superclass, it includes a practicumDuration (int). All applied courses have a practicum with a specified duration

Class CourseOffering: This class models a course scheduled and offered in the training institution. It has the course (Course) the course offering is for, startDate (GregorianCalendar), whether the course offering is isOpen (boolean) , the current vacancy (int) and a collection that records the studentList (ArrayList) enrolled in the course offering.

Class Student: This class models a student in the training institution. There are only two types of students: LocalStudent and InternationalStudent. Every student has a unique studentNumber (int), name (String), dateRegistered (GregorianCalendar) , id (String) and courseEnrolled (CourseOffering).

studentNumber is a system-generated running number starting with 1 for the first student, incremented by 1 for each subsequent student, and is to be displayed with the width of 8, with leading zeroes such as 00000001.

Class LocalStudent: This class is a subclass of Student. It models a local student in the training institution. It has no additional attribute apart from what it inherits from the superclass.

This class has a constant DEPOSIT_PERCENT to record the fixed percentage (0.3) for the deposit required for all local students.

Class InternationalStudent: This class is a subclass of Student. It models an international student in the training institution. In addition to the attributes it inherits from the superclass, it has a studentPass (String) to record the student pass number.

This class also has two constants: DEPOSIT_PERCENT and R_DEPOSIT_PERCENT to record the fixed percentage (0.5) for the deposit required and for refundable percentage (0.2) respectively for all international students.

Class TrainingInstitution: This class models the training institution. It has three collections: courses (ArrayList < Course>), offerings (ArrayList < CourseOffering>) and students (ArrayList < Student>).

Implement the Java class for Student as an abstract class. You should include the following in the class:

  • The instance and class variables according to the description given above.
  • The constructor that does all the necessary initializations given all necessary values including the day (int), month (int) and year (int) of the registration date
  • The get method for studentNumber and set method for courseEnrolled.
  • The toString() method that returns a string showing the values of all the attributes.
Below is an example in the required format:
00000001 Ishak Ahmad 24/2/2015 S9211111C
  • The abstract method getDepositPercent () that returns the percentage to deposit.

Implement the two Java subclasses of Student: LocalStudent and InternationalStudent. You should include the following in the classes:

  • The instance variable(s) and constant(s) according to the description given above.
  • The constructor that does all the necessary initializations except for studentPass which is obtained after the student has enrolled for a course and has applied for a student pass successfully.
  • The toString() method that returns a string the values of all the attributes. Below are examples in the required format:
- for local student:
00000001 Ishak Ahmad 24/2/2015 S9211111C

- for international student
00000003 Viva Sujurono 24/2/2015 D1122311A Not Obtained
  • In the case when the student pass is not obtained yet, the returned string includes Not Obtained. Otherwise, the value of studentPass should be included in the returned string.
  • The getDepositPercent()method that returns the percentage to deposit.

Implement the Java class for Course. You should include the following in the class:

  • The instance variable(s) according to the class description given above.
  • The constructor that will do all the necessary initializations.
  • The get and set methods wherever required.
  • The getDuration() method that returns lessonDuration.
  • The toString() method that returns a string the values of all the attributes. Below is an example in the required format:
Code: C111 Title: Basic Copywriting Fees(SGD): $535.00
Lesson Duration: 2 wks
  • Note that fees should be displayed as a number with 2 decimal places and with the unit wks if duration is more than 1 week or wk otherwise.

Implement the Java subclass of Course: AppliedCourse. You should include the following in the class:

  • The instance variable(s) according to the class description given above.
  • The constructor that will do all the necessary initializations.
  • The get and set methods wherever required.
  • The getDuration() method that returns sum of lessonDuration and practicumDuration.
  • The toString() method that returns a string with the values of all the attributes.
  • Below is an example with the same formatting requirement stated for Course:
Code: AC111 Title: Creating Newsletters Fees(SGD): $1872.50
Lesson Duration: 1 wk Practicum Duration: 3 wks

Implement the Java class CourseOffering. You should include the following in the class:

  • The instance variable(s) according to the class description given above.
  • Two constructors, one that that will do all the necessary initializations and the other that will set isOpen to false as default, in addition to the other necessary initializations.
  • The get and set methods wherever required.
  • The method changeIsOpen() that sets isOpen to true if currently false and to false if currently true.
  • The addStudent(Student) method to add a Student to the collection of students , studentList.
  • The getOfferingDetails()method that returns a string with the values of all the attributes but without the details of students enrolled. Below is an example in the required format:
Code: C111 Title: Basic Copywriting Fees(SGD): $535.00
Lesson Duration: 2 wks
Start Date: 24/8/2015 Status: Close Vacancy: 20
  • The toString() method that returns a string including with the values of all the attributes and with the details of students enrolled, in this format:
- for a course offering with no student enrolled:
Code: C111 Title: Basic Copywriting Fees(SGD): $535.00
Lesson Duration: 2 wks
Start Date: 24/8/2015 Status: Close Vacancy: 20 No students enrolled

- for a course offering with student(s) enrolled:
Code: AC222 Title: DigiFilm Production Fees(SGD): $16050.00
Lesson Duration: 24 wks
Practicum Duration: 36 wks
Start Date: 4/5/2015 Status: Open Vacancy: 2
Student Number Name Date Reg. ID Student Pass
00000003 Viva Sujurono 24/2/2015 D1122311A Not Obtained
00000001 Ishak Ahmad 24/2/2015 S9211111C

Complete the Java class TrainingInstitution given in appendix A as your prototype. Modify it to include the following methods:

  • listAllCourseDetail (ArrayList < CourseOffering> offerings) This method is invoked when the user chooses option 2. A sample run is shown here for this option, with user input underlined:
Menu ====
1. Enrol Course
2. List Course Offerings
0. Exit
Option: 2

Course Offering List
====================
Code: C111 Title: Basic Copywriting Fees(SGD): $535.00
Lesson Duration: 2 wks
Start Date: 20/4/2015 Status: Open Vacancy: 3
No students enrolled

Code: C111 Title: Basic Copywriting Fees(SGD): $535.00
Lesson Duration: 2 wks
Start Date: 24/8/2015 Status: Close Vacancy: 20
No students enrolled

Code: C222 Title: MSWord Processing Fees(SGD): $192.60
Lesson Duration: 1 wk
Start Date: 20/4/2015 Status: Close Vacancy: 0
No students enrolled

Code: AC111 Title: Creating Newsletters Fees(SGD): $1872.50
Lesson Duration: 1 wk Practicum Duration: 3 wks
Start Date: 27/4/2015 Status: Close Vacancy: 0
Student Number Name Date Reg. ID Student Pass
00000005 Irene Peters 26/2/2015 H1122313H Not Obtained

  • listAvailableCourseOffering (ArrayList < CourseOffering> offerings) The method displays only the course offerings that are open without the details of students enrolled.
A sample output is shown here:

Available Course Offerings
==========================
Code: C111 Title: Basic Copywriting Fees(SGD): $535.00
Lesson Duration: 2 wks
Start Date: 20/4/2015 Status: Open Vacancy: 3
  • searchStudent (ArrayList students, int studNo) This method returns a Student object with the given studNo. The method returns null if there is no such Student object in the collection students.
  • searchCourseOffering(ArrayList < CourseOffering> offerings, String code, int day, int mth, int year) This method returns a CourseOffering object with the given course code and the start date as specified by the arguments day, mth, year. The method returns null if there is no such CourseOffering object in the collection offerings.
  • enrol (ArrayList < CourseOffering> offerings, ArrayList < Student> students) This method is invoked when the user chooses option 1.
  • The method allows the user to enter a student number with which the system will search for the Student object. If the Student object is located, the system will check whether the student is already enrolled in a course. If so, the student will not be allowed to enrol in another course. Otherwise, the available courses offerings will be displayed. The user can then enter a course code followed by the start date with which the system will search for the course offering.
  • If the course offering is located, a check is made to see if the Student object is an InternationalStudent object and the course duration exceeds 4 weeks. If so, the system displays a message regarding the need to apply for a student pass and prompts the user whether he wishes to continue with the enrol procedure in view of the requirement. The system should repeatedly prompt until the user selects y (yes and so the enrolment procedure continues) or n (no and so the system displays a message and ends the enrolment process).
  • If the Student object is an InternationalStudent object who chooses to proceed or if the Student object is a LocalStudent object, the system
    • displays the amount of deposit to be paid (amount differs for LocalStudent and InternationalStudent) and simulates payment,
    • decrement the vacancy, sets the course offering to close if vacancy hits zero,
    • adds the student to the course offering,
    • adds the course offering to the course enrolled for the student.
  • The method should display a message to inform the user of the outcome of the enrolment attempt. The possible outcomes are:
    • the enrolment is successful
    • the student cannot be located
    • the course offering cannot be located
    • the student is already enrolled in a course.
    • the user has chosen not to proceed in view of the student pass requirement

You should make use of methods for individual task to make your program easier to follow. For each task, design your own interface, if necessary, and ensure that it is clear and friendly. You are not required to perform input validation except for those described. Therefore, do ensure that you enter only valid input when you execute the program at points where there is no validation.

Submit your program listing and the screenshot of the output to convince your tutor that your program is working. Your screenshot must show your name and student number.

Give an example of the following concepts used in the Java code for Question 1(a) to (f)

  • Method overriding
  • Polymorphism
  • Object composition
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.