Helpful Information
 
 
Category: Java
Very confusing...

Ok i am working on this program that deals with inheritance. I start out with a Student parent class then i am going to have a college, middle school, and high school children.

Currently i have got the middle school and almost have the high school. the middle school seems to be working fine but the high school is not even though they seem to be the same.

Here is my high school class

class HighSchool extends Student
{
int gradYear2, credLeft, SAT, apCred;
public HighSchool(String name, int age, String schoolName, int id, double gpa, int graduationYear, int creditLeft, int sat, int apCredit);
{
super(name, age, id, schoolName, gpa);
gradYear2 = graduationYear;
credLeft = creditLeft;
SAT = sat;
apCred = apCredit;
}

public String toString()
{
String temp = super.toString();
return temp + "Graduation Year: " +gradYear+ "\nCredits Left: "+credLeft+"\nSAT Score: "+SAT+"\nAP Credits Taken: "+apCred;
}

}

and here is my middle school


class MiddleSchool extends Student
{
int gradYear1;

public MiddleSchool(String name, int age, String schoolName, int id, double gpa, int gradYear)
{
super(name, age, id, schoolName, gpa);
gradYear1 = gradYear;
}

public String toString()
{
String temp = super.toString();
return temp + gradYear1;
}
}

the errors i am getting are :
HighSchool.java:4: missing method body, or declare abstract
public HighSchool(String name, int age, String schoolName, int id, double gpa, int graduationYear, int creditLeft, int sat, int apCredit);
^
HighSchool.java:6: call to super must be first statement in constructor
super(name, age, id, schoolName, gpa);
^
HighSchool.java:7: cannot find symbol
symbol : variable graduationYear
location: class HighSchool
gradYear2 = graduationYear;


any suggestions?

All caused by the extra semicolon here:
public HighSchool(String name, int age, String schoolName, int id, double gpa, int graduationYear, int creditLeft, int sat, int apCredit);Java convention (and common sense) would have you call them "HighSchoolStudent" and "MiddleSchoolStudent."

AHHH i knew it was somethign like that. i had looked at it like 10 times and didnt notice that...

thanks again!










privacy (GDPR)