TeamLeader Class In a particular factory, a team leader is an hourly paid produc
ID: 3569008 • Letter: T
Question
TeamLeader Class
In a particular factory, a team leader is an hourly paid production worker that leads
a small team. In addition to hourly pay, team leaders earn a fixed monthly bonus.
Team leaders are required to attend a minimum number of hours of training per year.
Design a TeamLeader class that extends the ProductionWorker class you designed in
Programming Challenge 1.
The TeamLeader class should have fields for the monthly bonus amount, the required
number of training hours, and the number of training hours that the team leader has
attended.
Write one or more constructors and the appropriate accessor and mutator methods for
the class.
Demonstrate the classes by running the provided demo program
TeamLeaderDemo.java
The output:
Here's the first team leader.
Name: John Smith
Employee Number: 123-A
Hire Date: 11-15-2005
Shift: Day
Hourly Pay Rate: $16.50
Monthly Bonus: $500.00
Required Training Hours: 5.0
Training Hours Attended: 2.5
Here's the second production worker.
Name: Joan Jones
Employee Number: 222-L
Hire Date: 12-12-2005
Shift: Night
Hourly Pay Rate: $18.50
Monthly Bonus: $600.00
Required Training Hours: 7.0
Training Hours Attended: 3.5
Explanation / Answer
import java.util.Scanner;
public class Test_Employee_worker {
public static void main(String[] args) {
Employee e=new Employee("Johnsmith","123-A","11-15-2005");
System.out.println("enter shift 1.day 2.night");
ProductionWorker pw=new ProductionWorker();
Scanner sc=new Scanner(System.in);
int s=sc.nextInt();
TeamLeader tl=new TeamLeader();
System.out.println("Name: "+e.getName());
System.out.println("Employee Number: "+e.getXXX_L());
System.out.println("Hire Date: "+e.getHireDate());
if(s==1){
pw.setHourly_pay_rate(16.50);
System.out.println("Shift: Day Hourly Pay Rate: $"+pw.getHourly_pay_rate());
tl.setMonthly_bonus_amount(500);
tl.setNumber_of_training_hours(5.0);
tl.setNumber_of_training_hours_of_TL(2.5);
}
else
{
pw.setHourly_pay_rate(18.50);
System.out.println("Shift: Night Hourly Pay Rate: $"+pw.getHourly_pay_rate());
tl.setMonthly_bonus_amount(600);
tl.setNumber_of_training_hours(7.0);
tl.setNumber_of_training_hours_of_TL(3.5);
}
System.out.println("Monthly Bonus: $"+tl.getMonthly_bonus_amount());
System.out.println("Required Training Hours:"+tl.getNumber_of_training_hours());
System.out.println("Training Hours Attended: "+tl.getNumber_of_training_hours_of_TL());
}
}
import java.util.Scanner;
public class Employee {
String name;
public Employee()
{
}
public Employee(String name, String xXX_L, String hireDate) {
super();
this.name = name;
XXX_L = xXX_L;
this.hireDate = hireDate;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getXXX_L() {
return XXX_L;
}
public void setXXX_L(String xXX_L) {
XXX_L = xXX_L;
}
public String getHireDate() {
return hireDate;
}
public void setHireDate(String hireDate) {
this.hireDate = hireDate;
}
String XXX_L;
String hireDate;
@Override
public String toString() {
return "Employee [name=" + name + ", XXX_L=" + XXX_L + ", hireDate="
+ hireDate + "]";
}
}
public class TeamLeader {
public TeamLeader(){}
public TeamLeader(int monthly_bonus_amount, double number_of_training_hours,
double number_of_training_hours_of_TL) {
super();
this.monthly_bonus_amount = monthly_bonus_amount;
this.number_of_training_hours = number_of_training_hours;
this.number_of_training_hours_of_TL = number_of_training_hours_of_TL;
}
public int getMonthly_bonus_amount() {
return monthly_bonus_amount;
}
public void setMonthly_bonus_amount(int monthly_bonus_amount) {
this.monthly_bonus_amount = monthly_bonus_amount;
}
public double getNumber_of_training_hours() {
return number_of_training_hours;
}
public void setNumber_of_training_hours(double number_of_training_hours) {
this.number_of_training_hours = number_of_training_hours;
}
public double getNumber_of_training_hours_of_TL() {
return number_of_training_hours_of_TL;
}
public void setNumber_of_training_hours_of_TL(
double number_of_training_hours_of_TL) {
this.number_of_training_hours_of_TL = number_of_training_hours_of_TL;
}
int monthly_bonus_amount;
double number_of_training_hours;
double number_of_training_hours_of_TL;
}
public class ProductionWorker extends TeamLeader {
public static final int DAY_SHIFT = 1;
public static final int NIGHT_SHIFT = 2;
public ProductionWorker()
{
}
@Override
public String toString() {
return "ProductionWorker [shift=" + shift + ", hourly_pay_rate="
+ hourly_pay_rate + "]";
}
int shift;
public ProductionWorker(int shift, double hourly_pay_rate) {
super();
this.shift = shift;
this.hourly_pay_rate = hourly_pay_rate;
}
public int getShift() {
return shift;
}
public void setShift(int shift) {
this.shift = shift;
}
public double getHourly_pay_rate() {
return hourly_pay_rate;
}
public void setHourly_pay_rate(double hourly_pay_rate) {
this.hourly_pay_rate = hourly_pay_rate;
}
double hourly_pay_rate;
}
o/p:
enter shift
1.day
2.night
1
Name: Johnsmith
Employee Number: 123-A
Hire Date: 11-15-2005
Shift: Day
Hourly Pay Rate: $16.5
Monthly Bonus: $500
Required Training Hours:5.0
Training Hours Attended: 2.5
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.