Hello, having a hard time using my Faculty class, where I have to initialize/createObject from my Education class to Faculty. I would like to use the constructors from the Education class, to be implemented to my Faculty class. Here is my attempt Here's my two codes.
public class Education {
String degree;
String major;
String research;
public Education()
{
degree = "";
major = "";
research = "";
}
public Education(String degree, String major, String research){
this.degree = degree;
this.major = major;
this.research = research;
}
public void setDegree(String degree)
{
this.degree = degree;
}
public String getDegree()
{
return degree;
}
public void setMajor(String major)
{
this.major = major;
}
public String getMajor()
{
return major;
}
public void setResearch(String research)
{
this.research = research;
}
public String getResearch()
{
return research;
}
}
This education is fine.
mport java.util.Calendar;
public class Faculty <T> extends Employee implements EmployeeInfo {
private String level;
Education degree = new Education();
Education major = new Education();
Education research = new Education();
/**
* Default constructor
*/
public Faculty() {
super();
}
public Faculty(String name, int idNumber, char gender, Calendar birthdate,
String level, Education degree, Education major, Education research ) {
super(name, idNumber, gender, birthdate);
this.level = level;
this.degree = degree;
this.major = major;
this.research = research;
}
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level;
}
public double monthlyEarning() {
// TODO Auto-generated method stub
return 0;
}
public boolean equals(Object o) {
if(o instanceof Faculty)
return getIdNumber() == ((Faculty) o).getIdNumber();
else
return false;
}
public String toString() {
return "\n\nID Employee Number: " + getIdNumber() +
"\nEmployee Name: " + getEmployeeName() +
"\nSex: " + getGender() +
"\nBirth date: " + getBirthdate().get(Calendar.YEAR) + "/" + getBirthdate().get(Calendar.MONTH) + "/" + getBirthdate().get(Calendar.DATE) +
"\nLevel: " + getLevel() +
"\nDegree:" + getDegree() + //This is what I want to work
"\nMonthly Salary: " + monthlyEarning();
}
This is my attempt. Line 51 is where I want to use "get.Degree". It can't access it from the Education class. The eclipse program wants me to create the method, which already did in my Education class. So any pointers is appreciate on how I can do this. I'll still play around the code though.