Question

In: Computer Science

use eclipse Develop the classes for the following requirements: 1. A class named Employee (general, for...

use eclipse

Develop the classes for the following requirements:

1. A class named Employee (general, for college)

2. A class named Instructor (more specific, for college)

3. A class named Staff (more specific, for college, HR officer, Marking staff)

Tasks:

1. Figure out the relationships among the classes;

2. Determine the abstract class, and the child classes;

3. For the abstract class, determine at least one abstract method;

4. Each class should at least two data members and one extra method;

5. Full implementation of all constructors, getters/setters and toString, and other methods;

6. Test your Java code and take screen shots

Solutions

Expert Solution

Here are the relationship details:

Employee Class will be abstract class with following members and abstract methods:

package university;

public abstract class Employee {
        
        int employeeId;
        String firstName;
        String lastName;
        int age;
        
        abstract String getFirstName();
        abstract String getLastName();
        abstract int getEmployeeId();
        abstract int getAge();
        abstract void setEmployeeId(int employeeId);
        abstract void setFirstName(String firstName) ;
        abstract void setLastName(String lastName) ;
        abstract  void setAge(int age);
}

Staff Class will extend Employee Class and have following members and methods:

package university;

public class Staff extends Employee{


        int staffId;
        String staffType;
        String department;
        
        

        public Staff(){}
        
        public Staff(int employeeId,
                        String firstName,
                        String lastName,
                        int age,String departmen, int staffId,String staffType){
                this.employeeId=employeeId;
                this.firstName=firstName;
                this.lastName=lastName;
                this.age=age;
                this.department=departmen;
                this.staffId=staffId;
                this.staffType=staffType;
        
        }


        @Override
        String getFirstName() {
                return firstName;
        }

        @Override
        String getLastName() {
                return lastName;
        }

        @Override
        int getEmployeeId() {
                return employeeId;
        }

        @Override
        int getAge() {
                return age;
        }

        @Override
        void setEmployeeId(int employeeId) {
                this.employeeId=employeeId;

        }

        @Override
        void setFirstName(String firstName) {
                this.firstName=firstName;

        }

        @Override
        void setLastName(String lastName) {
                this.lastName=lastName;         
        }

        @Override
        void setAge(int age) {
                this.age=age;
        }
        
        public int getStaffId() {
                return staffId;
        }

        public void setStaffId(int staffId) {
                this.staffId = staffId;
        }

        public String getStaffType() {
                return staffType;
        }

        public void setStaffType(String staffType) {
                this.staffType = staffType;
        }

        public String getDepartment() {
                return department;
        }

        public void setDepartment(String department) {
                this.department = department;
        }
        @Override
        public String toString(){
                return "Staff Details:"
                                + "\nFirst Name:"+firstName+
                                "\nLast Name:"+lastName+
                                "\nAge:"+age+
                                "\nEmployee ID:"+employeeId+
                                "\nStaff ID:"+staffId+
                                "\nStaff Type:"+staffType+
                                "\nDepartment:"+department;
        }
        
}

Instructor class will extent Employee Class and have following members and methods:

package university;

public class Instructor extends Employee{


        //To which department does instructor belongs
        String department;
        //Instructor Id(different from employee id)

        int instructorId;
        
        String instrcutorType;

        

        public Instructor(){

        }

        public Instructor(int employeeId,
                        String firstName,
                        String lastName,
                        int age,String departmen, int instructorId){
                this.employeeId=employeeId;
                this.firstName=firstName;
                this.lastName=lastName;
                this.age=age;
                this.department=departmen;
                this.instructorId=instructorId;

        }


        public String getDepartment() {
                return department;
        }


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


        public int getIntstructorId() {
                return instructorId;
        }


        public void setIntstructorId(int instructorId) {
                this.instructorId = instructorId;
        }


        @Override
        String getFirstName() {
                return firstName;
        }

        @Override
        String getLastName() {
                return lastName;
        }

        @Override
        int getEmployeeId() {
                return employeeId;
        }

        @Override
        int getAge() {
                return age;
        }

        @Override
        void setEmployeeId(int employeeId) {
                this.employeeId=employeeId;

        }

        @Override
        void setFirstName(String firstName) {
                this.firstName=firstName;

        }

        @Override
        void setLastName(String lastName) {
                this.lastName=lastName;         
        }

        @Override
        void setAge(int age) {
                this.age=age;
        }
        
        public int getInstructorId() {
                return instructorId;
        }

        public void setInstructorId(int instructorId) {
                this.instructorId = instructorId;
        }

        public String getInstrcutorType() {
                return instrcutorType;
        }

        public void setInstrcutorType(String instrcutorType) {
                this.instrcutorType = instrcutorType;
        }

        @Override
        public String toString(){
                return "Instructor Details:\n"
                                + "First Name:"+firstName+
                                "\nLast Name:"+lastName+
                                "\nAge:"+age+
                                "\nEmployee ID:"+employeeId+
                                "\nInstructor ID:"+instructorId+
                                "\nDepartment:"+department+
                                "\nInstructor Type:"+instrcutorType;
        }
}

MainClass to test the code:

package university;

public class MainClass {

        public static void main(String[] args) {
                
                Staff staff=new Staff();
                Staff staff2=new Staff();
                Instructor instructor=new Instructor();
                Instructor instructor2=new Instructor();
                
                staff.setFirstName("John");
                staff.setLastName("Carpenter");
                staff.setAge(30);
                staff.setEmployeeId(123);
                staff.setStaffId(001);
                staff.setDepartment("HR");
                staff.setStaffType("HR officer");
                
                staff2.setFirstName("William");
                staff2.setLastName("Doffe");
                staff2.setAge(35);
                staff2.setEmployeeId(124);
                staff2.setStaffId(002);
                staff2.setDepartment("Marketing");
                staff2.setStaffType(" Marking staff");
                
                instructor.setFirstName("John");
                instructor.setLastName("Carpenter");
                instructor.setAge(30);
                instructor.setEmployeeId(125);
                instructor.setInstructorId(011);
                instructor.setDepartment("Physics");
                instructor.setInstrcutorType("Physics Lecturer");
                
                instructor2.setFirstName("Steve");
                instructor2.setLastName("Smith");
                instructor2.setAge(30);
                instructor2.setEmployeeId(126);
                instructor2.setInstructorId(012);
                instructor2.setDepartment("Physics");
                instructor2.setInstrcutorType("Physics Lab Instructor");
                
                System.out.println(staff.toString());
                System.out.println("\n");
                System.out.println(staff2.toString());
                System.out.println("\n");
                System.out.println(instructor.toString());
                System.out.println("\n");
                System.out.println(instructor2.toString());
                
        }

}

Output:

Staff Details:
First Name:John
Last Name:Carpenter
Age:30
Employee ID:123
Staff ID:1
Staff Type:HR officer
Department:HR


Staff Details:
First Name:William
Last Name:Doffe
Age:35
Employee ID:124
Staff ID:2
Staff Type: Marking staff
Department:Marketing


Instructor Details:
First Name:John
Last Name:Carpenter
Age:30
Employee ID:125
Instructor ID:9
Department:Physics
Instructor Type:Physics Lecturer


Instructor Details:
First Name:Steve
Last Name:Smith
Age:30
Employee ID:126
Instructor ID:10
Department:Physics
Instructor Type:Physics Lab Instructor

Screenshot of output:


Related Solutions

Design a class named Employee. The class should keep the following information in fields: ·         Employee...
Design a class named Employee. The class should keep the following information in fields: ·         Employee name ·         Employee number in the format XXX–L, where each X is a digit within the range 0–9 and the L is a letter within the range A–M. ·         Hire date Write one or more constructors and the appropriate accessor and mutator methods for the class. Next, write a class named ProductionWorker that inherits from the Employee class. The ProductionWorker class should have fields...
In an eclipse or blues compatible code, please create a class named Items including the described...
In an eclipse or blues compatible code, please create a class named Items including the described methods (replace and delete0 Write the following static method: /** Replaces each occurrence of an oldItem in aList with newItem */ public static void replace(ArrayList<String>aList, String oldItem, String newItem) Write the following static method: /**Deletes the first occurrence of target in aList*/ public static void delete(ArrayList<String>aList, String target)
Using C#: Write a class named Employee that has the following properties: Name - The Name...
Using C#: Write a class named Employee that has the following properties: Name - The Name property holds the employee's name IdNumber - The IdNumber property holds the employee's ID number Department - The Department property holds the name of the department in which the employee works Position - The Position property holds the employee's job title The class should have the following overloaded constructors: A constructor that accepts the following values as arguments and assigns them to the appropriate...
C++ PersonData and CustomerData classes Design a class named PersonData with the following member variables: lastName...
C++ PersonData and CustomerData classes Design a class named PersonData with the following member variables: lastName firstName address city state zip phone Write the appropriate accessor and mutator functions for these member variables. Next, design a class named CustomerData, which is derived from the PersonData class. The CustomerData class should have the following member variables: customerNumber mailingList The customerNumber variable will be used to hold a unique integer for each customer. The mailingList variable should be a bool. It will...
Using Eclipse IDE Create a Java Program/Class named MonthNames that will display the Month names using...
Using Eclipse IDE Create a Java Program/Class named MonthNames that will display the Month names using an array. 1. Create an array of string named MONTHS and assign it the values "January" through "December". All 12 months need to be in the array with the first element being "January", then "February", etc. 2. Using a loop, prompt me to enter an int variable of 1-12 to display the Month of the Year. Once you have the value, the program needs...
Java Question Design a class named Person and its two subclasses named Student and Employee. Make...
Java Question Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, and date hired. Use the Date class to create an object for date hired. A faculty member has office hours and a rank. A...
In general, is it better to use named or unnamed parameters?
In general, is it better to use named or unnamed parameters?
Write in C++ language. (Employee Record): Create a class named 'Staff' having the following members: Data...
Write in C++ language. (Employee Record): Create a class named 'Staff' having the following members: Data members - Id – Name - Phone number – Address - AgeIt also has a function named 'printSalary' which prints the salary of the staff.Two classes 'Employee' and 'Officer' inherits the 'Staff' class. The 'Employee' and 'Officer' classes have data members 'Top Skill' and 'department' respectively. Now, assign name, age, phone number, address and salary to an employee and a officer by making an...
IN JAVA PLEASE, USE COMMENTS Following the example of Circle class, design a class named Rectangle...
IN JAVA PLEASE, USE COMMENTS Following the example of Circle class, design a class named Rectangle to represent a rectangle. The class contains: • Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height. • A no-arg constructor that creates a default rectangle. • A constructor that creates a rectangle with specified width and height • A method name getWidth() return the value...
In this Question using c++, you are to develop an employee management system using classes. You...
In this Question using c++, you are to develop an employee management system using classes. You need to develop two classes: Date and Employee. The Date class has the three attributes (int): month, day, and year. The class has the following member functions: • string getDate(void): returns a string with the date information (e.g, Mach 27, 2020). In addition to these, declare and implement proper constructors, a copy constructor, a destructor, and getters and setters for all data members. The...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT