Starting from:

$25

CSIT121 - Lab 5 - Solved

• Familiar with Java text file I/O and object serialization.

 

Background: 

 

In Assignment 2, both the Bachelor and Master of Computer Science course structures are inputted manually inside the main() method. The students’ enrolment records cannot be kept as well. In Lab 5, you are asked to modify the A2’s solution by using the object serialization and file I/O to import/export course objects and export the students’ enrolment records to a text file.

 

Tasks: 

 

Task 1:

1.      Modify the existing Course, Subject and Major classes by implementing the serializable interface;

2.      Create a new primary class (CreateCourse) without any class field;

3.      Use the ObjectOutputStream class in the main() method of CreateCourse class to output the Bachelor of Computer Science course object to a binary file named bcs.ser (within the same directory as the CreateCourse.java) and the Master of Computer Science course object to a binary file named mcs.ser.You shall re-use the hardcode in A2’s solution to create all subject, major and course objects first. Then use the writeObject() method to export the two course objects to two binary files, respectively.

 

Task 2:

1.      Update the StudentSystem class in A2’s solution (you can use your or my A2 solution) with the exception handling process completed in Lab 4;

2.      Update the StudentSystem class and use the ObjectInputStream class to import the Bachelor of Computer Science course object and the Master of Computer Science course object from the binary files bcs.ser and mcs.ser (created in Task 1), respectively;

3.      Enrol two students to BCS and MCS course respectively (exactly same process as A2);

4.      Export all students’ enrolment record information (the exactly same information displayed on the screen after the completion of the two students’ enrolment in A2) into a text-file named students.txt (within the same directory as the StudentSystem.java). You must use the Formatter class and the format() method.

 


More products