a little help with my java assignment?

minofifa

Senior member
May 19, 2004
485
0
0
When i run this code

-------------------------------
public class Undergrad extends Student {

private String major;
private String minor;

/* when called, the constructor for "Undergrad" sets up the proper fields, including major and minor
* It takes two strings as perameters.
*/

public Undergrad (String surname, String firstName, String stdID, int gpa, String minor, String major){
super(surname,firstName,stdID,gpa);
this.minor = minor;
this.major = major;
}

------------------------------------------

i get the following error

"implicit suprconstructor Student() is undefined, must explicitly invoke another constructor.

it is true that i don't hae a Student() constructor defined in my superclass (that takes no perameters). i don't want ther to be one. i only want the one that i made to be called by the subclass when i pass it the proper perameters. My Student constructor looks like this:

public Student (String surname, String firstName, String stdID, int gpa){..}.

any ideas on how to fix this? thanks.
 

ruijorge

Member
May 12, 2006
53
0
0
Are you sure you have public Student (String surname, String firstName, String stdID, int gpa){..} in Student´s class?
If you do, do you have all the parameters initialized?
 

minofifa

Senior member
May 19, 2004
485
0
0
ahh, that's the problem. i didnt know i had to initialize the variables. thank you.