Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You have been hired by the Sandwich Queen Company to help organize their employe

ID: 3573060 • Letter: Y

Question

You have been hired by the Sandwich Queen Company to help organize their employees.

Create an Employee superclass which contains:

   - A field for name

   - A field for payrate

   - A constructor that assigns the fields

Create a class called SandwichArtisan which extends Employee and contains:

   - A field for the number of sandwiches made per hour

   - A field for customers served per hour

   - Appropriate constructor and accessors

Create a class called QueenManager which extends Employee and contains:

   - A field for the number of employees managed

   - A field for the paybonus the manager receives

   - A void method that calculates the paybonus as:

       paybonus = total customers served per hour * 2

         The method must take an array of SandwichArtisans as an argument to calculate the total customers served by all the artisans.

       Store the result in your class field.

   - Appropriate constructor and accessors

Write a main class which creates 1 QueenManager and 3 SandwichArtisans, making up values for their fields (no need to ask the user).

Add the 3 SandwichArtisans to an array and use it to calculate the paybonus of the Manager.

Output the name and paybonus earned by the manager.

Search your array for the employee with the most customers served and output the name of that employee as the employee of the month.

Name your main class Hw7pr1 and your file Hw7pr1.java.

Explanation / Answer

import java.util.ArrayList;
import java.util.List;

class Employee{
   private String name;
   private double payRate;
   public Employee(String name, double payRate) {
       super();
       this.name = name;
       this.payRate = payRate;
   }
   public Employee() {
       super();
   }
   public String getName() {
       return name;
   }
   public void setName(String name) {
       this.name = name;
   }
   public double getPayRate() {
       return payRate;
   }
   public void setPayRate(double payRate) {
       this.payRate = payRate;
   }  
  
}
class QueenManager extends Employee{
   private int noOfEmployeesManaged;
   private double payBonus;
  
  
   public QueenManager() {
       super();
       // TODO Auto-generated constructor stub
   }

   public QueenManager(String name, double payRate, int noOfEmployeesManaged, double payBonus) {
       super(name, payRate);
       this.noOfEmployeesManaged = noOfEmployeesManaged;
       this.payBonus = payBonus;
   }
  
   public int getNoOfEmployeesManaged() {
       return noOfEmployeesManaged;
   }
   public void setNoOfEmployeesManaged(int noOfEmployeesManaged) {
       this.noOfEmployeesManaged = noOfEmployeesManaged;
   }
   public double getPayBonus() {
       return payBonus;
   }
   public void setPayBonus(double payBonus) {
       this.payBonus = payBonus;
   }
  
   public void calculatePayBonus(List<SandwichArtisan> artisanList){
       int customersServed = 0;
       for(SandwichArtisan artisan: artisanList){
           customersServed += artisan.getCustomersServedPerHour();
       }
       payBonus = customersServed * 2;
   }
  
}
class SandwichArtisan extends Employee{
   private int noOfSandwichesMadePerHour;
   private int customersServedPerHour;
  
   public SandwichArtisan() {
       super();
       // TODO Auto-generated constructor stub
   }
   public SandwichArtisan(String name, double payRate, int noOfSandwichesMadePerHour, int customersServedPerHour) {
       super(name, payRate);
       this.noOfSandwichesMadePerHour = noOfSandwichesMadePerHour;
       this.customersServedPerHour = customersServedPerHour;
   }
   public int getNoOfSandwichesMadePerHour() {
       return noOfSandwichesMadePerHour;
   }
   public void setNoOfSandwichesMadePerHour(int noOfSandwichesMadePerHour) {
       this.noOfSandwichesMadePerHour = noOfSandwichesMadePerHour;
   }
   public int getCustomersServedPerHour() {
       return customersServedPerHour;
   }
   public void setCustomersServedPerHour(int customersServedPerHour) {
       this.customersServedPerHour = customersServedPerHour;
   }
  
  
}

public class Hw7pr1 {
  
   public static void main(String args[]){
       QueenManager qm = new QueenManager("Elizabeth", 12012, 3, 0);
       SandwichArtisan a = new SandwichArtisan("a", 123, 10, 10);
       SandwichArtisan b = new SandwichArtisan("b", 123, 20, 10);
       SandwichArtisan c = new SandwichArtisan("c", 123, 10, 10);
       List<SandwichArtisan> list = new ArrayList<>();
       list.add(a);
       list.add(b);
       list.add(c);
       qm.calculatePayBonus(list);
       System.out.println("Manager name : "+ qm.getName() + " payBonus : "+ qm.getPayBonus());
      
       SandwichArtisan maxArtisan = getSandwichArtisanByMostCustomersServed(list);
       if(maxArtisan != null){
           System.out.println("Employee of the month : "+ maxArtisan.getName());
       }
   }
  
   public static SandwichArtisan getSandwichArtisanByMostCustomersServed(List<SandwichArtisan> artisanList){
           if(artisanList == null || artisanList.size() == 0) return null;
           SandwichArtisan maxArtisan = null;
           int maxCustomersServed = 0;
           for(SandwichArtisan artisan: artisanList){
               if(maxCustomersServed < artisan.getCustomersServedPerHour() * artisan.getNoOfSandwichesMadePerHour()){
                   maxArtisan = artisan;
                   maxCustomersServed = artisan.getCustomersServedPerHour() * artisan.getNoOfSandwichesMadePerHour();
               }
           }
           return maxArtisan;
   }

}
/**
Output :
Manager name : Elizabeth   payBonus : 60.0
Employee of the month : b

* **/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote