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

USE JAVA Develop the classes for the following requirements: 1. A class named Employee (general, for...
USE JAVA 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...
JAVA Design a class named Person and its two derived classes named Student and Employee. Make...
JAVA Design a class named Person and its two derived classes named Student and Employee. Make Faculty and Staff derived classes of Employee. A person has a name, address, phone number, and e-mail address. A student has a class status (freshman, sophomore, junior, or senior). An employee has an office, salary, and datehired. Define a class named MyDate that contains the fields year, month, and day. A faculty member has office hours and a rank. A staff member has a...
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...
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...
JAVA LANGUAGE Create a new project named BankAccount in Eclipse. Then, implement the following requirements. You...
JAVA LANGUAGE Create a new project named BankAccount in Eclipse. Then, implement the following requirements. You need to create two classes, one for BankAccount (BankAccount.java) and the other for the tester (BankAccountTest.java). Make sure your program compile without errors before submitting. Submit .java files to eCampus by the end of next Thursday, 10/15/2020. Part 1: Create the BankAccount class (template is attached after the project description) in the project. You must add the following to the BankAccount class: An instance...
Create a class named Employee and its child class named Salesperson. Save each class in its...
Create a class named Employee and its child class named Salesperson. Save each class in its own file. Name your class and source code file containing the main method homework.java. Make sure each class follows these specifications: 1. An employee has a name (String), employee id number (integer), hourly pay rate (double), a timesheet which holds the hours worked for the current week (double array) and email address (String). A salesperson also has a commission rate, which is a percentage...
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)
C++ program to implement Matrix Class with following requirements, Classes :- matrix.cpp and main.cpp (to test...
C++ program to implement Matrix Class with following requirements, Classes :- matrix.cpp and main.cpp (to test it) with following requirements: - Please use Vectors of double. Declare and define an matrix class: - The matrix stores doubles. Implement a default constructor which initializes square 1 x 1 matrix that contains  0.0. Implement a constructor that accepts a positive integer n and creates a square n x n matrix that contains 0.0s. Throw an exception if the integer passed to the constructor...
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...
open up a new Java project on Eclipse named Review and create a new class called...
open up a new Java project on Eclipse named Review and create a new class called Review.java. Copy and paste the below starter code into your file: /** * @author * @author * CIS 36B */ //write your two import statements here public class Review {        public static void main(String[] args) { //don't forget IOException         File infile = new File("scores.txt");         //declare scores array         //Use a for or while loop to read in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT