Create a Employee java class with attributes name yearsofexp
Create a “Employee” java class with attributes: name, years_of_experience, and methods of getting those attributes;
Create a subclass “Faculty” under “Employee” with attributes: department, years_of_teaching and method of getting those attributes;
Create an Interface “PrintInfo” with an abstract method for \"print_info\";
Solution
PrintInfo.java
public interface PrintInfo {
void print_info();
}
________________
Employee.java
public class Employee {
private String name;
private int years_of_experience;
public Employee() {
}
public Employee(String name, int years_of_experience) {
this.name = name;
this.years_of_experience = years_of_experience;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getYears_of_experience() {
return years_of_experience;
}
public void setYears_of_experience(int years_of_experience) {
this.years_of_experience = years_of_experience;
}
}
______________________________
Faculty.java
public class Faculty extends Employee {
private String department;
private int years_of_teaching;
public Faculty(String name,int years_of_experience,String department, int years_of_teaching) {
super(name, years_of_experience);
this.department = department;
this.years_of_teaching = years_of_teaching;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public int getYears_of_teaching() {
return years_of_teaching;
}
public void setYears_of_teaching(int years_of_teaching) {
this.years_of_teaching = years_of_teaching;
}
}
________________________
