Next, design a class named ProductionWorker that extends the Employee class. The
ID: 3543942 • Letter: N
Question
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
Explanation / Answer
package employment; //import java.util.Calendar; import org.joda.time.DateTime; public class Employee { String Name; String hireDate; int employeeNum; //The following constructor accepts arguments for the employee's name, //hire date, and id number: public Employee(String name, String aHireDate, int empNum) { Name = name; hireDate = aHireDate; employeeNum = empNum; } public static void main(String[] args) {//will soon move main method to //ProductionWorkerDemo class String Name; String hireDate; int employeeNum; //declare a variable here with current date and time to calculate how //long an employee has been with the company //Write one or more constructors and the appropriate accessor and //mutator methods for the class. (Note that "accessor methods" are //getters, and "mutator methods" are setters): //The setName method accepts an argument //that is stored in the Name field. public void setName(String name)//error: "illegal start of expression" { Name = name; } //The setHireDate method accepts an argument //that is stored in the Name field. public void setHireDate(String aHireDate) { hireDate = aHireDate; } //The setEmployeeNum method accepts an argument //that is stored in the payRate field. public void setEmployeeNum(int empNum) { employeeNum = empNum; } //The getName method returns the value //stored in the Name field. public String getName() { return Name; } //The getPayRate method returns the value //stored in the payRate field. public String getHireDate() { return hireDate; } //The getPayRate method returns the value //stored in the payRate field. public int getEmployeeNum() { return employeeNum; } }//end of main method }//end of Employee class (the super class)//error: "class, interface, or enum expected" //Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - illegal start of expression //at employment.Employee.main(Employee.java:45) //Java Resu/lt: 1 Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.