I'm getting an error in my code (it's the last line of my assignment and I can't seem to solve it) which is in the addStudent method. It says my attempt to access an overloaded constructor is actually attempting to access the default constructor, and that there are no variables for me to pass through. So, in a nutshell:
"studentArray[i] = new Student(firstname, lastname, gender, sClass, sID);"
is trying to access:
"public void Student(){}"
but I want it to access:
"public void Student(String firstname, String lastname, String gender, String sClass, String sID)"
Thanks for the help!
-AndresL
public void Student()
{
setFirstName("Unknown");
setLastName("Unknown");
setGender("Unknown");
setClass("Freshman");
setID("0000");
}
public void Student(String firstname, String lastname, String gender, String sClass, String sID)
{
setFirstName(firstname);
setLastName(lastname);
setGender(gender);
setClass(sClass);
setID(sID);
}
public static boolean addStudent(String firstname, String lastname, String gender, String sClass, String sID)
{
for (int i=0; i<studentArray.length; i++)
{
if (studentArray[i] == null)
{
studentArray[i] = new Student(firstname, lastname, gender, sClass, sID);
totStudent++;
}else {JOptionPane.showMessageDialog(null, "Max students reached.");}
}
return true;
}