Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. a. In previous chapters, you have created several classes for Carly's Catering. Now, create a new abstract class named Employee. The class contains data

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

1. a. In previous chapters, you have created several classes for Carly's Catering. Now, create a new abstract class named Employee. The class contains data fields for an employee's ID number, last name, first name, pay rate, and job title. The class contains get and set methods for each field; the set methods for pay rate and job title are abstract. Save the file as Employee.java. b. Create three classes that extend Employee named Waitstaff, Bartender, and Coordinator. The method that sets the pay rate in each class accepts a parameter and assigns it to the pay rate, but no Waitstaff employee can have a rate higher than 10.00, no Bartender can have a rate higher than 14.00, and no Coordinator can have a rate higher than 20.00. The method that sets the job title accepts no parameters-it simply assigns the string waitstaff, bartender, or coordinator to the object appropriately. Save the files as Waitstaff.java, Bartender.java, and Coordinator.java. c. In Chapter 10, you created a DinnerEvent class that holds event information, including menu choices. Modify the class to include an array of 15 Employee objects representing employees who might be assigned to work at a DinnerEvent. Include a method that accepts an Employee array parameter and assigns it to the Employee array field, and include a method that returns the Employee array. The filename is DinnerEvent.java. d. Write an application that declares a DinnerEvent object, prompts the user for an event number, number of guests, menu options, and contact phone number, and then assigns them to the object. Also prompt the user to enter data for as many Employees as needed based on the number of guests. A DinnerEvent needs one Waitstaff Employee for every event, two if an event has 10 guests or more, three if an event has 20 guests or more, and so on. A DinnerEvent also needs one Bartender for every 25 guests and one Coordinator no matter how many guests attend. All of these Employees should be stored in the Employee array in the DinnerEvent object. (For many events, you will have empty Employee array positions.) After all the data values are entered, pass the DinnerEvent object to a method that displays all of the details for the event, including all the details about the Employees assigned to work. Save the program as StaffDinnerEvent.java. public abstract class Employee private String employeeNumber; private String lastName; private String firstName; protected double payRate; protected String jobTitle; public void set EmployeeNumber(String num) employeeNumber = num; public void setLastName(String name) lastName = name; public void setFirstName(String name) { firstName = name; public String getEmployeeNumber() return employeeNumber; public String getName() return firstName + " " + lastName; public double getPayRate() return payRate; public String getJobTitle() return jobTitle; public abstract void setPayRate(double rate); public abstract void set JobTitle(); public class Waitstaff extends Employee public final static double PAY_RATE - 10.00; public void setPayRate(double rate) if(rate > PAY_RATE) payRate = PAY_RATE; else payRate = rate; public void setJobTitle() jobTitle = "waitstaff"; public class Bartender extends Employee public final static double PAY_RATE = 14.00; public void setPayRate (double rate) if(rate > PAY_RATE) payRate = PAY_RATE; else payRate = rate; public void setJobTitle) jobTitle = "bartender"; public class Coordinator extends Employee public final static double PAY_RATE - 20.00; public void setPayRate(double rate) if(rate > PAY_RATE) payRate = PAY_RATE; else payRate = rate; public void setJobTitle) job Title = "coordinator"; class DinnerEvent extends Event public final static String[] ENTREES = {"beef", "chicken", "fish", "pasta"}; public final static String[] SIDES = {"salad", "mixed vegetables", "baked potato", "garlic bread", "dinner roll"}; public final static String[] DESSERTS = {"chocolate cake", "apple pie", "butterscotch pudding"}; private int entreeChoice; private int sideChoicel; private int sideChoice2; private int dessertChoice; Employee[] emps = new Employee[15]; public DinnerEvent(String num, int guests, int choicel, int choice2, int choices, int choice4) super(num, guests); if (choicel PAY_RATE) payRate = PAY_RATE; else payRate = rate; public void setJobTitle() jobTitle = "waitstaff"; public class Bartender extends Employee public final static double PAY_RATE = 14.00; public void setPayRate (double rate) if(rate > PAY_RATE) payRate = PAY_RATE; else payRate = rate; public void setJobTitle) jobTitle = "bartender"; public class Coordinator extends Employee public final static double PAY_RATE - 20.00; public void setPayRate(double rate) if(rate > PAY_RATE) payRate = PAY_RATE; else payRate = rate; public void setJobTitle) job Title = "coordinator"; class DinnerEvent extends Event public final static String[] ENTREES = {"beef", "chicken", "fish", "pasta"}; public final static String[] SIDES = {"salad", "mixed vegetables", "baked potato", "garlic bread", "dinner roll"}; public final static String[] DESSERTS = {"chocolate cake", "apple pie", "butterscotch pudding"}; private int entreeChoice; private int sideChoicel; private int sideChoice2; private int dessertChoice; Employee[] emps = new Employee[15]; public DinnerEvent(String num, int guests, int choicel, int choice2, int choices, int choice4) super(num, guests); if (choicel

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions

Question

What would you do?

Answered: 1 week ago