For a homework assignment the instructions state (within Undergrad class):
You do NOT need to include a default constructor, but you must write a full parameterized constructor (it takes 4 arguments) -- this constructor calls the parent class parameterized constructor and the mutator for year level.
Because Undergrad extends Student, then Student is my parent class, right? I just can't quite figure out how I'm to use my year level mutator (which is just the simplest of methods) to assign my "year" attribute.
public void setYear(int inYear)
{
year = inYear;
}
public Student(String inName, String inID, int inCredits)
{
name = inName;
id = inID;
credits = inCredits;
}
public Undergrad(String inName, String inID, int inCredits,int inYear)
{
super(inName, inID, inCredits);
year = inYear;
}
I keep missing assignments because I spend too much time on these small specific points of the homework so just aski开发者_C百科ng for a little help. I swear it's the wording that throws me off on these assignments almost as often as just learning the material itself.
I believe they want you to use the setter in order to set the year instead of setting the year directly.
public Undergrad(String inName, String inID, int inCredits,int inYear)
{
super(inName, inID, inCredits);
setYear(inYear);
}
精彩评论