Question

Define a class named Employee . Derive this class from the class Person. An employee record...

Define a class named Employee . Derive this class from the class Person. An employee record inherits an employee's name from the class Person. In addition, an employee record contains an annual salary (represented by a single value of type double), a hire date that gives the year hired (as a single value of type int), an identification number of type int, and a department of type String. Give your class a reasonable complement of constructors, accessors, mutators, an equals method and a WriteOutput method. Two employees are equal if their IDs are equal. Write a main method to FULLY test your class definition.

THEN upload ONLY your Person.java and Employee.java file to Canvas.

Constructors (one default, one with all info)

Accessors (salary, hireDate, ID, department)

Mutators(salary,hireDtae, ID, department)

equals

WriteOutput

IN JAVA

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change. 

Below are the Person.java and Employee.java classes

Thank You !

===========================================================================

public class Person {

   protected String fName;
   protected String lName;

    public Person() {
        this.fName = "";
        this.lName="";
    }

    public Person(String fName, String lName) {
        this.fName = fName;
        this.lName = lName;
    }

    public String getfName() {
        return fName;
    }

    public String getlName() {
        return lName;
    }
    
    public String getFullName(){
        return getfName()+" "+getlName();
    }
    
    
}

===================================================================

public class Employee extends Person {

    private double annualSalary;
    private int hiresDate;
    private int identificationNo;
    private String department;

    public Employee() {
        super();
        annualSalary = 0;
        hiresDate = 0;
        identificationNo = 0;
        department = "";
    }

    public Employee(double annualSalary, int hiresDate, int identificationNo, String department) {
        this.annualSalary = annualSalary;
        this.hiresDate = hiresDate;
        this.identificationNo = identificationNo;
        this.department = department;
    }

    public Employee(String fName, String lName, double annualSalary, int hiresDate, int identificationNo, String department) {
        super(fName, lName);
        this.annualSalary = annualSalary;
        this.hiresDate = hiresDate;
        this.identificationNo = identificationNo;
        this.department = department;
    }

    public double getAnnualSalary() {
        return annualSalary;
    }

    public int getHireDate() {
        return hiresDate;
    }

    public String getDepartment() {
        return department;
    }

    public void setAnnualSalary(double annualSalary) {
        this.annualSalary = annualSalary;
    }

    public void setIdentificationNo(int identificationNo) {
        this.identificationNo = identificationNo;
    }

    public void setHiredDate(int hiresDate) {
        this.hiresDate = hiresDate;
    }

    public void setDepartment(String department) {
        this.department = department;
    }

    public boolean equals(Employee employee) {
        return identificationNo == employee.identificationNo;
    }

    // write output
    public String printDetails() {
        return
                "Name: " + getFullName() +
                        "Salary $" + annualSalary +
                        ", Hire Date: " + hiresDate +
                        ", Identification No: " + identificationNo +
                        ", Department: " + department;

    }
}

===================================================================

Add a comment
Know the answer?
Add Answer to:
Define a class named Employee . Derive this class from the class Person. An employee record...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Design and write a class named Employee that inherits the Person class from the previous exercise...

    Design and write a class named Employee that inherits the Person class from the previous exercise and holds the following additional data: ID number, department and job title. Once you have completed the Employee class, write a Python program that creates three Employee objects to hold the following data: Name ID Number Department Job Title Phone Susan Meyers 47899 Accounting Vice President 212-555-1212 Mark Jones 39119 IT Programmer 212-555-2468 Joy Rogers 81774 Operations Engineer 212-555-9753 The Python program should store...

  • It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming...

    It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming Challenge 2 Employee Class.pdf Program Template: // Chapter 13, Programming Challenge 2: Employee Class #include <iostream> #include <string> using namespace std; // Employee Class Declaration class Employee { private: string name; // Employee's name int idNumber; // ID number string department; // Department name string position; // Employee's position public: // TODO: Constructors // TODO: Accessors // TODO: Mutators }; // Constructor #1 Employee::Employee(string...

  • Goal: In this lab, we will practice how to apply both the inheritance and composition concepts...

    Goal: In this lab, we will practice how to apply both the inheritance and composition concepts to write a Department class. 1. Implement the Department Class. Implement the following class: public class Department{ * The basic feature of a department */ private String deptName; private int numMajors; private Teacher[] list Teachers; //inherits from Person class private Student[] listStudents; //inherits from Person class /* Construct a department object (at least TWO constructors) */ * Accessors and mutators (one pair per each...

  • Using C++, Write a class named Employee that has the following member variables: name. A string...

    Using C++, Write a class named Employee that has the following member variables: name. A string that holds the employee's name. idNumber. An int variable that holds the employee's ID number. department. A string that holds the name of the department where the employee works. position. A string that holds the employee's job title. The class should have the following constructors: A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee's name,...

  • create a Person class with two fields (name(String), age(int)) create all the required methods such as...

    create a Person class with two fields (name(String), age(int)) create all the required methods such as the accessors, mutators, toString(),constructors etc. Use the comparable interface and implement the compareTo method such that the person objects can be compared and sorted according to their age.

  • With Java Language: In this assignment, you are to create a class named Payroll. In the...

    With Java Language: In this assignment, you are to create a class named Payroll. In the class, you are to have the following data members: name: String (5 pts) .İd: String (5 pts) hours: int (5 pts) rate: double (5 pts) private members (5 pts) You are to create no-arg and parameterized constructors and the appropriate setters(accessors) and getters (mutators). (20 pts) The class definition should also handle the following exceptions: An employee name should not be empty, otherwise an...

  • Write a C++ program Write a class named Employee that has the following member variables: name...

    Write a C++ program Write a class named Employee that has the following member variables: name A string that holds the employee name idNumber An int to hold employee id number department A string to hold the name of the department position A string to hold the job position The class will have three constructors: 1. A constructor that accepts all the internal data such as: Employee susan("Susan Meyers", 47899, "Accounting", "Vice President"); 2. A constructor that accepts some of...

  • In header file (.h) and c++ file format (.cpp). A local company has asked you to...

    In header file (.h) and c++ file format (.cpp). A local company has asked you to write a program which creates an Employee class, a vector of Employee class objects, and fills the objects with employee data, creating a "database" of employee information. The program allows the user to repeatedly search for an employee in the vector by entering the employee's ID number and if found, display the employee's data. The Employee_C class should have the following data and in...

  • //*Manager.java*// public interface Manager { public void handleCrisis(); } _________________________________________________________ /**Employee.java**/ Public abstract class Employee {...

    //*Manager.java*// public interface Manager { public void handleCrisis(); } _________________________________________________________ /**Employee.java**/ Public abstract class Employee { protected final String name; protected final int id; public Employee(String empName, int empId) { name = empName; id = empId; } public Employee() { name = generatedNames[lastGeneratedId]; id = lastGeneratedId++; } public String getName() { return name; } public int getId() { return id; } //returns true if work was successful. otherwise returns false (crisis) public abstract boolean work(); public String toString() { return...

  • c++ only Design a class representing an Employee. The employee would have at least these private...

    c++ only Design a class representing an Employee. The employee would have at least these private fields (Variables): name: string (char array) ID: string (char array) salary: float Type: string (char array) All the variables except for the salary should have their respective setters and getters, and the class should have two constructors, one is the default constructor and the other constructor initializes the name,ID and type of employee with valid user input. The class should have the following additional...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT