Starting from:

$30

CSC220-Lab 10 Class Hierarchy and Inheritance in Java Solved

In this lab, you are going to play with class hierarchy and exercise on inheritance in Java. 

 

Java programs:

 

Suppose that we are required to model students and teachers in our application. We can define a superclass called Person to store common properties such as name and address, and subclasses Student and Teacher for their specific properties. An object of the type CourseTaken is used to store a course a student takes and the grade the student gets for this course. For students, we need to maintain the courses taken and their respective grades using the class CourseTaken; add a course with grade, print all courses taken and the average grade. A student takes at least 5 courses. For teachers, we need to maintain 2 courses taught currently. 

 

The UML diagram for Person and its subclasses is as follows:

 According to the requirement, implement these three classes. Write a Test driver class that does the following:

1.     Create a student object s with your name and your address. 

2.     Print out the information of object s. 

                                                                       1

3.     Add 6 courses with grades for each of the courses for student s.

4.     Print out the grades and the average grade of student s.

5.     Create a teacher t with one of your teachers’ name and an address.

6.     Print out the information of object t. 

7.     Set two courses that teacher t teaches. 

Print out the courses that teacher t teaches

More products