CS 1311 Spring 2001 Assignment 14 Revised 4/17/2001: Clarified Extra Credit Requirements Added info about turnin for EC Due 9:00 a.m. April 20, 2001 via WebWork A friend of yours own a restaurant. She wants to be high tech so she's asked you to create a waiting list program. Here is what it must be able to do: The head waiter will run the program and when a customer arrives and asks for a table the head waiter will be able to enter into the program necessary information about the customer. This will include Name and number in party. This information will go to the back or bottom of the list. When a table is ready the head waiter will get from the program the next customer in the waiting line. All necessary information plus any special instructions will need to be displayed. [If you are not screaming to yourself, "It's a Queue!!!" then put yourself on report.] There are some special requirements: In addition to "normal" customers there are three categories of special customers: Someone is having a birthday! Will need to store the name to be written on the cake as well as how many candles. What a cute baby! Need to store the name of the baby plus a code indicating what type of food the baby will be throwing. Also need to know if its a boy or a girl since they want to put a pink or blue balloon on the table to remind the waitstaff to avoid the thrown food. Daddy is having a baby. Sometimes a man in a group will be having a nice dinner with his friends while his pregnant wife is in the hospital undergoing labor. If the hospital calls and says the little one is arriving, it will be necessary to know the name of the new dad, which taxi cab company he prefers and the name of the hospital. Experience has shown that the new dad will be too nervous to handle these details for himself. So here is what you need to do: 1. (5 points) Write a class LLNode like the one you wrote for Assignment 12 only this time the data reference should be a reference to an object. So as before, make sure that the field names are exactly: data and next. ---> Don't forget a toString method and a test main 2. (20 points) Using your new LLNode write a Queue class. It should support the following functionality: public boolean isEmpty() public void enqueue(Object o) [Hint: This should add to the end of the linked list. Best way is to use a tail reference (or pointer).] public Object dequeue() [Hint: This should remove the head of the linked list remembering to return its value before deleting it.] If the queue is empty, dequeue should return null public Object peek() [Hint: Like dequeue it returns the value of the data reference of the first item in the queue but it does not delete the node] ---> Don't forget the test main 3. (10 points) Write a class Customer It should have: a String party (e.g. like "The Smith party) an int number (e.g. the number of persons in the party) A toString method which returns: name + " party of " + number() inputData method -- Gets all fields from user e.g.: public void inputData() { party = IOGadget.readLine("Enter the name of the party"); etc. } 4. (15 points) Write three subclasses (extends) of class Customer: class BirthdayParty String cakeName int candles toString should call parent class toString plus add on a new line: "Birthday cake for: " + cakeName + " with " + candles + " candles" inputData method -- Calls superclass inputData method and then gets all other fields from user class AnnoyingBaby String babyName int foodChoice (1 - Gruel 2 - Pulverized Peas 3 - Mashed Potatoes 4 - Grits) Note: You must use an array to handle the food choices. boolean isPink true : girl (i.e. Pink balloon) false : boy (i.e. Blue balloon) toString should call parent class toString plus add on new line: Baby on board: Jennifer will be throwing: Grits Pink balloon on table. inputData method -- Calls superclass inputData method and then gets all fields from user class PregnantFather String dadName String taxiPhone String hospital toString should call parent class toString plus add on new line: Expectant Father: Bob prefers taxi from Yellow Cab to take him to Grady Hospital Place Red balloon on table. inputData method -- Calls superclass inputData method and then gets all fields from user 5. (20 points) Write a class HeadWaiter (this is the driver) with the following functionality: has-a Queue [which means it has a reference to a Queue] The constructor will initialize the Queue plus any other necessary variables (if there are any) private int displayMainMenu() Enter: 1 to add a customer to the waiting list 2 to display the next customer on the list 3 to seat the next customer on the list 4 to quit Choice?: private int displaySubMenu() Enter: 1. For a standard customer 2. For a birthday party 3. For a party with a baby 4. For a party with an expectant dad private void newCustomer() This is the method that asks the user which type of customer to add to the list (using displaySubMenu). It then creates the appropriate object and tells it to ask the user to fill in the data (inputData method). Note make sure you use polymorphism!!! It then Enqueues the customer object. private void nextCustomer This is the method that displays the customer at the head of the list without removing the customer from the list. Note: We are expecting that you will display the information by invoking the toString method. If you want to call some other method additional trickiness will be required. See your TA or instructor. private void tableReady() This is the method that takes care of removing the first customer from the list and displaying their information on the screen. public void startup() This method will enter into a loop where the following sequence will occur: displayMenu (which returns the headwaiters choice) If the choice is 1 invoke newCustomer() If the choice is 2 Invoke nextCustomer() If the choice is 3 Invoke tableReady() If the choice is 4 Exit the method Cranking it up: public static void main(String args[]) { /*------------------------------------------------------------ * * Here you need to make a HeadWaiter object and * tell it to run its startup method. * *------------------------------------------------------------ } 6. (15 points) Extra Credit Assume that in general customer parties can be classified into two sizes: big and little. Further assume that the restaurant has two sizes of tables: big and little. Little tables hold up to 4 people. Big tables hold up to 8 people. Add in functionality two provide two lists: One for big tables, one for little tables. The autograding team has asked me to ask you to name the two queues: bigtable and littletable So now an additional question (Big or little?) must be asked when either of the following menu choices are selected. 2 to display the next customer on the list 3 to seat the next customer on the list The submenu for this should display: 1. Small table 2. Big table. Note: When entering customers, the program will figure out which list to put them on automatically. In other words, based on the size of the party the program should enqueue the customer onto the correct queue. Assume that this is a perfect world and the number in the party will never exceed 8. ================================================ There will be a special turnin for Extra Credit. ================================================ Grading Problem 1: 5 points 2: 20 3: 10 4: 15 5: 20 Style 30 (Includes comments, indentation, clear easy to read code, constants, use of test mains,etc.) --- 100 Problem 6: (EC) 15 --- Max possible 115 Turnin Turn in all files (both .java and .class) to WebWork. You don't need to turn in IOGadget. If you choose not to do the extra credit then you just turn in Assignment 14 If you do the extra credit, you will turn in to Assignment 14 Extra Credit If you do the extra credit, you don't need to turn in an Assignment 14