Question
Create a Faculty class, and a Staff class. The Faculty class should have an attribute to store the Faculty's title (a String) for example Instructor,
Create a Faculty class, and a Staff class. The Faculty class should have an attribute to store the Faculty's title (a String) for example "Instructor", "Assistant Professor". The Staff class should have an attribute called pay grade (an integer from 1 to 20)
There must be:
Correct Attributes, a default constructor, a constructor with parameters, accessors, mutators, a writeOutput, and they must also derive classes from Employee.
Code I have thus far.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
package testemployee;
public class TestEmployee { //Main mehtod public static void main(String[] args) { //Employee objects Employee e1 = new Employee("Zion", 50000, 2020, "A100"); e1.display(); //Display employee details Employee e2 = new Employee("Bill", 60000, 2021, "A101"); e2.display(); Employee e3 = new Employee("Kamal", 70000, 2022, "A102"); e3.display(); System.out.println("Is Employee 1 and 3 the same?" + e1.equals(e3)); }//end of main method }// end TestEmployee class
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
package testemployee;
//Class Employee public class Employee extends Person { //Data members private double annualSalary; private int hiredYear; private String ID; //Constuctor with parameters eployee name, salary, date, and id public Employee(String initialName, double initialSalary, int joinedYear, String id) { //Calls base class constructor super(initialName); annualSalary = initialSalary; hiredYear = joinedYear; ID = id; } //Sets annual Salary public void setAnnualSalary(double newSalary) { annualSalary = newSalary; } //Sets hired year public void setHiredYear(int year) { hiredYear = year; } //Sets employee ID public void setID(String newID) { ID = newID; } //Returns annual salary public double getAnnualSalary() { return annualSalary; } //Returns hired year public int getHiredYear() { return hiredYear; } //Returns employee ID public String getID() { return ID; } //Returns true if both employee objects are same //otherwise returns false public boolean equals(Employee otherEmployee) { if (name.equals(otherEmployee.name)) if (annualSalary == otherEmployee.annualSalary) if (hiredYear == otherEmployee.hiredYear) if (ID == otherEmployee.ID) return true; return false; } //Prints the employee name, annual salary,hired year, and ID public void display() { System.out.println("Employee Name: " + name); System.out.println("Employee Annual Salary: " + annualSalary); System.out.println("Employee Hired Year: " + hiredYear); System.out.println("Employee ID: " + ID); System.out.println(); } }//end of Employee class
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package testemployee;
public class Person { //Person Name protected String name; //Default constructor public Person() { name = "No Name Yet"; } //1-argument constuctor sets initialName public Person(String initialName) { name = initialName; } //Sets new name public void setName(String newName) { name = newName; } //Returns person name public String getName(){ return name; } //Writes person name to the console public void writeOutput(){ System.out.println("Name : " + name); } //Returns true if names are same otherwise returns false public boolean hasSameName(Person otherPerson) { return this.name.equalsIgnoreCase(otherPerson.name); } }//end of Person class
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started