*Will add more time and points(over 1500+). Please help and write comments to ex
ID: 3565267 • Letter: #
Question
*Will add more time and points(over 1500+). Please help and write comments to explain steps. Really want to learn. New to Java. Thanks
Want to making a queue system for a restaurant (similar to Chilies, Red lobster etc) Objective is to determine the average amount of time people spend waiting for tables. The program should come from a short text file. Arrival party has arrived to eat. Add them to the end of the list of waiting parties a Queue and tell them to wait until called. So the output should say The parties name, number of people, wait time and total avergae wait time.
I need to output something like this. Welcome guest. Please enter data file name: data.txt party Steven Jack of 2 people. (time=9) Table for Bob! (time=10) Please wait at the bar, party Bill of 2 people. (time=12) Table for Steve Jack(time=11) Please wait, party The Guy of 3 people. (time=17) Table for Bill! (time=20) The average waiting time was: 7.1
Explanation / Answer
/* Need to figure out the range of future reservation.--Next two weeks. Need to clarify buffet or entees? Suppose one group table = */ public class Restaurant{ Rinfo rinfo; TableManager tm; } class TableManager{ HashMap resWithName;//Used to locate customers. HashMap resWithDate;//Used to check availiability. // e.g. Jan.5 -> Table1> // Table1> int Table tables; ArrayList waitingList;//Can be designed as a command pattern.When a cancelation request come, check if there is available spot for customer. int numOfTable; int numOfLarge; int numOfMedium; int numOfTable; public TableManager(){ //TODO set numbers. } public void reservResult(Request r){ if (processRequest(r)){ System.out.println("Successed!"); } else{ "You are on the waiting list or please change your reservation information."; } } private boolean processRequest(Request r){ HashMap request = fitTable(r.seats);//Parse what type of request(Small, Medium, Large). boolean isReserved = isAvailable(r.date, request, r.ts); if (isReserved){ //Update resWithName, resWithDate. } } private boolean isAvailable(Date date, HashMap request, TimeSpan ts){ boolean isReserved = false; //HashMap res = resWithDate.get(date);//Get a list of reserved tables at that time. //ArrayList start, end; // start = res.get(ts.start); // end = res.get(ts.end); Iterator i = request.iterator(); while (i.hasNext()){ MapEntry temp = MapEntry(i.next()); if (temp.key() == "Small"){ int[] result = findTable("Small", temp.value()); } else if(temp,key()=="Medium"){ } else{ } Update(); //check each request can be satified or not. //zhuo zi ke yi nuo de ya hun dan !!! } } private int[] findTable(String type, int num, Date date, TimeSpan ts){ int[] result = new int[num]; if (type == "Small"){ for (int i = 0 ; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.