Reputation: 1015
Seems like a pointless post when you look at the title but i've been scouting SO for hours for a solution with no luck, maybe the screen is blinding me -_-
Anyway, the overloaded constructor of a particular class is throwing me a "cannot find symbol" compiler error and i've no idea why. The code causing my issue is this:-
public Student(String fname, String sname, int age, string ID, String avgGradeStr, String projectedGradeStr, String progTitle, int avgGradeInt, int projectedGradeInt, int progID, double attendance)
and the error originates at the "int avgGradeInt"
argument.
Not to bombard you with code, the full class is as follows and if needed I can post the Person class also.
package DoC;
import java.util.*;
class Student extends Person
{
protected String avgGradeStr, projectedGradeStr, progTitle;
protected int avgGradeInt, projectedGradeInt, progID;
protected double attendance;
//CONSTRUCTOR
public Student()
{
fname="Not";
sname="Set";
avgGradeStr="Not Set";
ID="Not Set";
projectedGradeStr="Not Set";
progTitle="Not Set";
avgGradeInt=0;
projectedGradeInt=0;
progID=0;
attendance=0;
}
//CONSTRUCTOR (OVERLOADED)
public Student(String fname, String sname, int age, string ID, String avgGradeStr, String projectedGradeStr, String progTitle, int avgGradeInt, int projectedGradeInt, int progID, double attendance)
{
fname=this.fname;
sname=this.sname;
age=this.age;
ID=this.ID;
avgGradeStr=this.avgGradeStr;
projectedGradeStr=this.projectedGradeStr;
progTitle=this.progTitle;
avgGradeInt=this.avgGradeInt;
projectedGradeInt=this.projectedGradeInt;
progID=this.progID;
attendance=this.attendance;
}
//GETTERS
//get average grade string
protected String getAvgGrade()
{
return avgGradeStr;
}
//get average grade integer
protected int getAvgGradeInt()
{
return avgGradeInt;
}
//get projected grade string
protected String getProjectedGrade()
{
return projectedGradeStr;
}
//get projected grade int
protected int getProjectedGradeInt()
{
return projectedGradeInt;
}
//get attendance
protected double getAttendance()
{
return attendance;
}
//get programme-of-study ID
protected int getProgrammeID()
{
return progID;
}
//get programme-of-study title
protected String getProgrammeTitle()
{
return progTitle;
}
//END GETTERS
//START SETTERS
//set programme id
protected void setProgrammeID(int progID)
{
try{
progID=this.progID;
}
catch(Exception e)
{
System.out.println("setProgrammeID() error: " + e);
}
}
//set programme title
protected void setProgrammeID(String progTitle)
{
try{
progTitle=this.progTitle;
}
catch(Exception e)
{
System.out.println("setProgrammeTitle() error: " + e);
}
}
//set average grade string
protected void setAvgGrade(String avgGradeStr)
{
try{
avgGradeStr=this.avgGradeStr;
}
catch(Exception e)
{
System.out.println("setAvgGrade() error: " +e);
}
}
//set average grade int
protected void setAvgGradeInt(int avgGradeInt)
{
try{
avgGradeInt=this.avgGradeInt;
}
catch(Exception e)
{
System.out.println("setAvgGradeInt() error: " +e);
}
}
//set projectede grade string
protected void setProjectedGrade(String projectedGradeStr)
{
try{
projectedGradeStr=this.projectedGradeStr;
}
catch(Exception e)
{
System.out.println("setProjectedGrade() error: " +e);
}
}
//set projectede grade int
protected void setProjectedGradeInt(int projectedGradeInt)
{
try{
projectedGradeInt=this.projectedGradeInt;
}
catch(Exception e)
{
System.out.println("setProjectedGrade() error: " +e);
}
}
//END SETTERS
} //END CLASS
As always, any help greatly appreciated guys!
Upvotes: 1
Views: 2696
Reputation: 93842
string ID
should be String ID
(there's no string
class in the Java API).
Also note that you should swap your assignments in your constructor. Same for your setters.
I really recommend you to use an IDE (like Eclipse). You'll be able to correct these errors much more faster, than asking here =).
Upvotes: 4
Reputation: 3017
Well, I see that you have string ID
instead of String ID
. Sometimes mistakes like that cause the compiler to freak out and end up reporting the problem somewhere else.
Upvotes: 1