a GraduateStudent class, which extends Student (Seen below), whichs add: i. Appr
ID: 3642968 • Letter: A
Question
a GraduateStudent class, which extends Student (Seen below), whichs add:i. Appropriate constructor taking as input a person, string (studentId), int and string (major)
ii. String major variable, read-only, cannot be null or 0-length
iii. String minor variable, read-write, can be null, cannot be 0-length
public class Student {
Person person;
String studentId;
Integer graduationYear;
public Student(Person p, String id, int year) throws Exception {
if (p == null || id == null || id == "" || year < 2000)
throw new Exception("Bad Entry");
this.person = p;
this.studentId = id;
this.graduationYear = year;
}
public Integer getGraduationYear() {
return graduationYear;
}
public Person getPerson() {
return person;
}
public String getStudentId() {
return studentId;
}
public void setGraduationYear(Integer graduationYear) {
this.graduationYear = graduationYear;
}
}
Explanation / Answer
public class GraduateStudent extends Student {
private String major;
private String minor;
public GraduateStudent(Person p, String id, int year, String major) throws Exception {
super(p,id,year);
if(major != null && major.length() > 0) {
this.major = major;
}
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.