Computer Science 221 Program 7




Learning
objective:


To use abstract
classes and methods.

To use
polymorphism.





Assignment:

Write
a Java application that expands the student grade system from Program 6. Make
any necessary corrections to Program 6.



Since
a faculty member is a person, create a class Faculty that is derived from Person.
A faculty member has a department (String) and an ArrayList of
courses (ArrayList<Course). The difference is
that faculty doesn't get a grade in a course, but has a number of students.
This number should be included when the faculty's course is added. When the
faculty information is printed, the total
number of students should be printed (instead of a grade).



This
in turn means that Course is slightly different
for student and faculty. Both have a department (String), a number (int),
and credit hours (int). The student has a
grade (char), and the faculty has a number
of students (int). So make a new hierarchy with
an abstract class Course at the top that
contains common information. From this derive new classes StuCourse
and FacCourse that contain respectively the
grade and the number of students, with appropriate setters and getters. Make
all methods in Course that will be redefined
in the subclasses abstract methods.



In
Test.java add some faculty with courses
and number of students per course. Add grades to all of the students' courses.
Make an array of Person and put all students,
graduate students and faculty into it. Use a loop to print all information on
all Persons. I reserve the right to use my Test.java
in place of yours.



Signatures of constructors that
will be called from Test.java:

Student
(int idNumber, String firstName, String lastName)

Student
(int idNumber, String firstName, String lastName,

String major)

GraduateStudent
(int idNumber, String firstName, String lastName,

String major)

Faculty
(int idNumber, String firstName, String lastName,

String department)



Signatures of constructors that
will be called indirectly when anyone adds a course:

Course
(String newDept, int newNumber, int newHours)

//
for students:

StuCourse
(String newDept, int newNumber, int newHours)

//
for faculty:

FacCourse
(String newDept, int newNumber, int newHours, int newNumStu)



Signatures of methods that will
be called from Test.java:

//
for students:

setMajor(String
major)

addThesisTopic(String
thesisTopic)

addCourse(String
dept, int num, int hours)

changeGrade(String
dept, int num, char grade)

//
for faculty:

addCourse(String
dept, int num, int hours, int numStudents)



Submission
instructions:

Upload
the files Course.java, StuCourse.java, FacCourse.java, Person.java, Student.java,
GraduateStudent.java, Faculty.java,
and Test.java to "Program 7". Do not
submit class files or any of the BlueJ control files. Be sure to press the
submit button.



Policies:

The
policies given on WebCT are in effect for this and all assignments.



You
may submit on WebCT multiple times, so there is no excuse for not submitting
partial solutions.
Powered by