I have two classes, Staff
and AdvancedStaff
, which extends the former.
Staff
has this constructor:
public Staff (String number, String title, String name, String role, char level) {
staffNumber = number;
staffTitle = title;
staffName = name;
staffRole = role;
payScaleLevel = level;
}
I'll note that all instance variables have been set to private.
While, Advanced Staff
has this constructor:
public AdvancedStaff (String number, String title, String name) {
super(number, title, name);
role = "Entry level Advanced Staff";
level = 'A';
}
However, this throws a "symbol not found" error for my Staff
constructor.
I've tried using super.staffRole = "Entry level Advanced Staff";
but the private scope of my superclass prevents this.
I've found that adding the fields String role
and char level
to my AdvancedStaff
constructor allows me to call the super constructor, but I'm wondering if there's a way to call the super constructor without passing all of its arguments in my subclass constructor?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…