Hi every1, i have trouble doing my homework. Could anyone help. the probelm is everytime when i set the degree and it prints out the last degree i entered. when i use the default constructor (withour entering any infomation) to create the UndergradStudent instance, it doesn't allow me to set the degree. :-|
Here are my codes:
public class UndergradStudent extends CollegeStudent
{
public UndergradStudent()
{
super();
}
public UndergradStudent(String studentName, String studentId,
int graduationYear, String degreeSought)
{
super(studentName, studentId, graduationYear, degreeSought); // must be first
} // end constructor
public void setDegree(String degreeSought)
{ if (degree=="BA")
{ degree = degreeSought;
System.out.println("This studet has assigned to a BA degree.");
}
else if (degree == "BS")
{degree = degreeSought;
System.out.println("This studet has assigned to a BS degree.");
}
else
{ degree="";
System.out.println("Undergraduate student could only assign to a BA or BS degree");
}
}
public String getDegree()
{
return degree;
}// end getDegree
}
If you need to see my superclass code, please check my attachment