You have been asked to extend a pre-existing class Student
that represents a college student. A student has a name, a year (such as 1 for freshman and 4 for senior), and a set of courses that he/she is taking.
The Student
class includes the following members:
Member |
Description |
private String name
private int year
private Set<String> courses
|
private data of each student
|
public Student(String name, int year)
|
constructs a student with the given name and year; initially not taking any courses
|
public void addCourse(String name)
|
adds the given course to this student's set of courses
|
public void dropAll()
|
removes the student from all of his/her courses
|
public int getCourseCount()
|
returns number of courses the student is taking
|
public String getName()
|
returns student's name
|
public double getTuition()
|
returns the amount of money the student pays for tuition each year, which is $1,234.50 per course
|
public int getYear()
|
returns student's year, from 1 (freshman) to 4 (senior)
|
You are to define a new class called GradStudent that extends Student through inheritance. A GradStudent should behave like a Student except for the following differences:
-
A grad student keeps track of a research advisor, which is a professor working with the student.
-
Grad students are considered to be 4 years further ahead than typical students. So, for example, a grad student in year 1 of grad school is really in year 5 of school overall.
-
Grad students can enroll in a maximum of 3 courses at a time. If a grad student tries to add additional courses beyond 3, the course is not added to the student's set of courses.
-
Grad students pay tuition differently than other students. If the grad student is enrolled in 1 course or no courses, the grad student pays a flat rate of tuition of $500.00. If the grad student is enrolled in 2 or 3 courses, he/she pays twice as much as the normal student rate for those courses.
-
If grad students work too much, they become "burnt out." A burnt-out student is one who is in his/her 5th or higher year of grad school (9th or higher year of school overall) or one who is taking 3 courses.
You should provide the same methods as the superclass, as well as the following new behavior.
Constructor/Method |
Description |
public GradStudent(String name, int year, String advisor)
|
constructs a graduate student with the given name, given year (where 1 is the first year of grad school, 5th year of school overall; etc.), and research advisor
|
public String getAdvisor()
|
returns this grad student's research advisor
|
public boolean isBurntOut()
|
returns true if grad student is "burnt out" (in at least the 5th year of grad school, and/or taking 3 courses)
|
You must also make GradStudent
objects comparable to each other using the Comparable
interface. GradStudent
s are compared by year in ascending order, breaking ties by count of courses in ascending order, and further breaking ties by advisor in ascending alphabetical order. In other words, a GradStudent
object with a lower year is considered to be "less than" one with a higher year. If two students have the same year, the one with a lower count of courses is considered to be "less than" one with a higher course count. If the two students have the same year and the same number of courses, the one whose advisor's name comes first in alphabetical order is considered "less." (You should compare the strings as-is and not alter their casing, spacing, etc.) If the two objects are the same by all three of these criteria, they are considered to be "equal."
The majority of your grade comes from implementing the correct behavior. Part of your grade also comes from appropriately utilizing the behavior you have inherited from the superclass and not re-implementing behavior that already works properly in the superclass.