Please help me fix this error:
constructor CollegeMember in class C10h1.CollegeMember cannot be applied to given types; required: java.lang.String,java.
The problem is your Student
constructor. It needs to chain to the CollegeMember
constructor, which it should do like this:
public Student(String name, int year, String telNumber) {
super(name, telNumber);
this.year = year;
}
Likewise for Professor
, just with rank
instead of year
Note that you don't need to set name
and telNumber
in those constructors - that's the job of the CollegeMember
constructor you're chaining to. It would also be better if you made all the fields private - then you wouldn't even be able to try to set those fields in the subclasses... which makes sense, as they're not the responsibility of the subclasses.