Objectives
- Familiar with Inheritance, Polymorphism and interface.
Task 1:
The student record application is described as follows.
Student class (abstract class)
- Name (first and last name)
- DOB
- Address
- Mobile number
- Student ID
Undergraduate Student class
- Name (first and last name)
- DOB
- Address
- Mobile number
- Student ID
- Current course
- Expected completed session (session, year)
Post-Graduate Student class
- Name (first and last name)
- DOB (date)
- Address
- Mobile number
- Student ID
- Current course
- Expected completed session (session, year)
- Previous degree
- Date of Completion of the previous degree (date)
Address class
- Street number
- Street name
- City
- State
- Postcode
- Country
Student System class
- students (ArrayList<Student>)
Test Code class
- Test the program (main())
Draw UML class diagrams and write java program with the below instructions.
- From the above information, draw the UML class diagram of the classes and the relationship between the classes.
- Write java program to construct the above class. Design your own methods for each class using the concept of OOP design principle.
- Design a StudentSystem class that keep the record of all students (i.e., an Arraylist of Student objects). In the StudentSystem class, design a student search method that takes an int (Student id) as the input and print all information of the student (overwrite toString() method for the printing).
- Write test code in the main method in the TestCode Class with the following steps:
- create an object of StudentSystem;
- create one undergraduate student (Student ID:100000) and one postgraduate student
(Student ID:200000) objects and add the two student objects to the student arraylist;
- use the student search method to search and print (using toString() and polymorphism) the information of the two students;
- use a for loop to go through the student arraylist and update the undergraduate students expected completion session to Spring 2022, and update the postgraduate students previous degree to Bachelor of Math(using instanceof and downcasting);
- use another for loop to print the updated information of the two students.
Task 2:
The University online shopping members system is briefly described in the below UML class diagram. Please complete the UML class diagram and write a java program following the below instructions.
- Write all the code to construct the below class in the diagram. Design your own methods for each class using the concept of OOP design principle.
- Implement all clone() methods (deep clone) for all classes that implements Clonable interface.
- Write test code in the main method in the TestCode Class and create a PhD object and a Undergraduate object and testing the clone() methods with this two objects.
Reviews
There are no reviews yet.