Java 2 exercises

sehj
a6_ex6.html

COMP 1020

 

Exercise #6

Download the complete student information program and add the following feature to it:

  1. There is still duplicate code in the deansHonourList() method in the two subclasses. This code can be moved into the superclass, but the two types of students have different criteria for being on the list. You can make it work without using instanceof or getClass(), and without adding any more if-else statements or instance variables. Make this change; there should be no deansHonourList() method in either GraduateStudent or UndergraduateStudent, and the getGPA() method can be removed. Hint: add another instance method to the superclass and override it in the subclasses as necessary; call that method in your deansHonourList() method.
  2. After making the change above, create another subclass of Student called VisitingStudent. A visiting student has all of the Student instance variables, plus a string that indicates which university the student is visiting from. A visiting student cannot be on the Dean's honour list; make sure the deansHonourList() method always returns false for them. Also make sure the toString() method includes the additional information.

Submit your four classes (Student, GraduateStudent, UndergraduateStudent, and VisitingStudent) by the due date specified in the course schedule.