Just quick: How do you call a mutator from within a constructor in the same class?

Posted by Blockhead on Stack Overflow See other posts from Stack Overflow or by Blockhead
Published on 2011-01-05T01:44:04Z Indexed on 2011/01/05 1:53 UTC
Read the original article Hit count: 570

Filed under:
|

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 asking 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.

© Stack Overflow or respective owner

Related posts about java

Related posts about homework