Re: Cannot Find Constructor
First off all, you don't have
public Student()
{
}
Also, I might add, that abstract classes cannot be initialized, at least not to themselves.
You cannot have
Student stu = new Student();
if you had a subclass of Student called MathStudent, you could
Student stu = new MathStudent();
Re: Cannot Find Constructor
I fear you may need a default constructor
public Student()
{
}
too if you're extending Student.
Re: Cannot Find Constructor
Code java:
public abstract class Student {
private String firstName;
private String lastName;
private int studentID;
private double gPA;
private String status;
private String mentor;
// default constructor needed for inheritance
public Student()
{
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public int getStudentID() {
return studentID;
}
public double getGPA() {
return gPA;
}
public String getStatus() {
return status;
}
public String getMentor() {
return mentor;
}
public void setFirstName(String fName){
firstName = fName;
}
public void setLastName(String lName) {
lastName = lName;
}
public void setStudentID(int sID) {
studentID = sID;
}
public void setGPA(double sGPA) {
gPA = sGPA;
}
public void setStatus(String sStatus) {
status = sStatus;
}
public void setMentor(String sMentor) {
mentor = sMentor;
}
public Student(String fName, String lName, int sID, double sGPA, String sStatus, String sMentor) {
firstName = fName;
lastName = lName;
studentID = sID;
gPA = sGPA;
status = sStatus;
mentor = sMentor;
}
public abstract void calculateTuition();
public abstract void update();
public abstract void add();
public abstract void delete();
public abstract void query ();
}
Code java:
public class Graduate extends Student {
// if graduate has similar characteristics of Student, then you should
public Graduate (String fName, String lName, int sID, double sGPA, String sStatus, String sMentor, otherVariables)
{
super (fName, IName, sID, sGPA, sStatus, sMentor); // calls constructor of superclass
otherVariables = this.otherVariables;
}
public void calculateTuition()
{
}
public void update()
{
}
public void add()
{
}
public void delete()
{
}
public void query ()
{
}
// other methods, and also a default constructor if you're planning on extending Graduate
// also, you don't need to have any methods defined here that were already written in Student, unless you're changing
// what they do or their parameters.
// Every method that was abstract in Student MUST be defined, or at least written like I did, in Graduate, otherwise,
// Graduate will have to be an abstract class too.
}
Re: Cannot Find Constructor
Ok, now it makes sense to me. Thank you very much!