Answer to Question #197747 in Java | JSP | JSF for Prince Emmanuel

Question #197747

3.Write an Employee class that keeps data attributes for the following pieces of

information:

a.Employee name

b.Employee number

Next,write a class named ProductionWorker that is a subclass of the Employee class.

The Production Worker class should keep data attributes for the following information:

c.Shiftnumber(an integer,such as 1 for morning shift,2 for evening shift)

d.Hourly payrate

Write the appropriate accessor and mutator methods for each class.


1
Expert's answer
2021-05-24T07:42:08-0400


class Employee{
	private String name;
	private String number;
	/**
	 * Constructor
	 * @param name
	 * @param number
	 */
	public Employee(String name,String number){
		this.name=name;	
		this.number=number;
	}
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the number
	 */
	public String getNumber() {
		return number;
	}
	/**
	 * @param number the number to set
	 */
	public void setNumber(String number) {
		this.number = number;
	}
}


class ProductionWorker extends Employee{
	//Shiftnumber(an integer,such as 1 for morning shift,2 for evening shift)	
	private int shiftnumber;
	//Hourly payrate
	private double hourlyPayrate;
	/**
	 * Constructor
	 * @param name
	 * @param number
	 * @param shiftnumber
	 * @param hourlyPayrate
	 */
	public ProductionWorker(String name,String number,int shiftnumber,double hourlyPayrate) {
		super(name, number);
		this.shiftnumber=shiftnumber;
		this.hourlyPayrate=hourlyPayrate;
	}	
	/**
	 * @return the shiftnumber
	 */
	public int getShiftnumber() {
		return shiftnumber;
	}
	/**
	 * @param shiftnumber the shiftnumber to set
	 */
	public void setShiftnumber(int shiftnumber) {
		this.shiftnumber = shiftnumber;
	}
	/**
	 * @return the hourlyPayrate
	 */
	public double getHourlyPayrate() {
		return hourlyPayrate;
	}
	/**
	 * @param hourlyPayrate the hourlyPayrate to set
	 */
	public void setHourlyPayrate(double hourlyPayrate) {
		this.hourlyPayrate = hourlyPayrate;
	}
	


}


public class Q197747 {


	public static void main(String[] args) {
		ProductionWorker productionWorker=new ProductionWorker("Mary Clark", "C12464654", 1, 15);
		System.out.println("Name: "+productionWorker.getName());
		System.out.println("Number: "+productionWorker.getNumber());
		System.out.println("Shift number: "+productionWorker.getShiftnumber());
		System.out.println("Hourly pay rate: "+productionWorker.getHourlyPayrate());
	}


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS