Design an Employee class that has fields for the following pieces of information: Next, design a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to hold the following information: The workday is divided into two shifts: day and night. The shift field will hold an integer value representing the shift that the employee works. The day shift is shift 1 and the night shift is shift 2.  Design the appropriate accessor and mutator methods for each class. Once you have designed the classes, design a program that creates an object of the ProductionWorker class and prompts the user to enter data for each of the object’s fields. Store the data in the object and then use the object’s accessor methods to retrieve it and display it on the screen. You are to submit the following for the assignment: You can use the generate dropdown to create example JAVA code based on your working logical flow chart to see what the code would look like.

Designing the Employee Class and the ProductionWorker Class

To design the Employee class, we need to identify the fields that represent the information to be stored for an employee. Based on the requirements, the Employee class should have the following fields:

1. Name: A string that represents the employee’s name.
2. Employee ID: An integer value that uniquely identifies the employee.
3. Shift: A string that represents the shift the employee works.

In addition to the fields, we also need to design the appropriate accessor and mutator methods for each field. The accessor methods will allow us to retrieve the values of the fields, and the mutator methods will enable us to modify the values of the fields.

Here is an example implementation of the Employee class in Java:

“`java
public class Employee {
// Fields
private String name;
private int employeeID;
private String shift;

// Accessor methods
public String getName() {
return name;
}

public int getEmployeeID() {
return employeeID;
}

public String getShift() {
return shift;
}

// Mutator methods
public void setName(String name) {
this.name = name;
}

public void setEmployeeID(int employeeID) {
this.employeeID = employeeID;
}

public void setShift(String shift) {
this.shift = shift;
}
}
“`

Once we have designed the Employee class, we can proceed to design the ProductionWorker class, which extends the Employee class. The ProductionWorker class should have additional fields to hold the following information:

1. Shift Number: An integer value representing the shift that the employee works. Day shift is represented by 1, and night shift is represented by 2.
2. Hourly Pay Rate: A double value representing the hourly pay rate of the production worker.

Here is an example implementation of the ProductionWorker class in Java:

“`java
public class ProductionWorker extends Employee {
// Fields
private int shiftNumber;
private double hourlyPayRate;

// Accessor methods
public int getShiftNumber() {
return shiftNumber;
}

public double getHourlyPayRate() {
return hourlyPayRate;
}

// Mutator methods
public void setShiftNumber(int shiftNumber) {
this.shiftNumber = shiftNumber;
}

public void setHourlyPayRate(double hourlyPayRate) {
this.hourlyPayRate = hourlyPayRate;
}
}
“`

Now that we have designed the Employee class and the ProductionWorker class, we can create a program that creates an object of the ProductionWorker class, prompts the user to enter data for each of the object’s fields, stores the data in the object, and then use the object’s accessor methods to retrieve and display the data.

The code implementation of the program would depend on the specific requirements and the programming language being used. However, the general logic would involve creating an instance of the ProductionWorker class and using input/output operations to interact with the user and set/retrieve the object’s fields.

Continuing the example in Java, here is a simplified example of such a program:

“`java
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
// Create an object of the ProductionWorker class
ProductionWorker worker = new ProductionWorker();

// Prompt the user to enter data for each field
Scanner scanner = new Scanner(System.in);

System.out.print(“Enter the name: “);
worker.setName(scanner.nextLine());

System.out.print(“Enter the employee ID: “);
worker.setEmployeeID(scanner.nextInt());

System.out.print(“Enter the shift (1 for day, 2 for night): “);
worker.setShiftNumber(scanner.nextInt());

System.out.print(“Enter the hourly pay rate: “);
worker.setHourlyPayRate(scanner.nextDouble());

// Display the data using the accessor methods
System.out.println(“Name: ” + worker.getName());
System.out.println(“Employee ID: ” + worker.getEmployeeID());
System.out.println(“Shift: ” + worker.getShift());
System.out.println(“Shift Number: ” + worker.getShiftNumber());
System.out.println(“Hourly Pay Rate: ” + worker.getHourlyPayRate());
}
}
“`

This program creates an object of the ProductionWorker class, prompts the user to enter data for each field, stores the data in the object using the mutator methods, and then retrieves and displays the data using the accessor methods.

In conclusion, the Employee class is designed to have fields for storing the name, employee ID, and shift information. The ProductionWorker class extends the Employee class and adds fields for shift number and hourly pay rate. The program interacts with the user to input the data and uses accessor methods to retrieve and display the stored information.

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Click Here to Make an Order Click Here to Hire a Writer