I DO NOT NEED YOU TO WRITE THE CODE!!! Please DESCRIBE IN DETAIL HOW YOU WOULD I
ID: 3704284 • Letter: I
Question
I DO NOT NEED YOU TO WRITE THE CODE!!! Please DESCRIBE IN DETAIL HOW YOU WOULD IMPLEMENT THE CODE. USE YOUR OWN WORDS AND MAKE IT ONE FULL PAGE LONG. DO NOT POST THE CODE!! Write a simulation program of the lines at agrocery store. The program will be similar tothe car wash simulation, except that thereare multiple queues instead of one. You might use avector of queues to simulate the lines. Assume thatthere are five cashier lines at the grocery store. Cus-tomers enter randomly to check out, and then enter the shortest line. If the lines are equal, then the firstavailable line is chosen. Each transaction takes arandom amount of time to complete.For additional work, expand the grocery line pro-gram to allow shoppers to: Avoid a line if all lines are a certain length.Leave a line if they have waited beyond a cer-tain time Check if another line is shorter at specifiedtime intervals.Switch lines if another line is shorterExplanation / Answer
Start off my defining the classes and data structures needed:
1) Vector of wQueues for sotring information about the lines.
2) Class Customer with the following attributes:
2.a) Line Number - To be initialized with a method say assignLine() which would take no input and check all the queues in O(n) time to determine the length of each of them and return the shortest among them or the first available if all are of same length, also taking into consideration the aspect like avoiding a line if it is too long, etc.
2.b) Time spent in a line- To be initialized with zero and incremented by 1s after a line is assigned to the person.
2.c) ID- To store the information in the vector of queues.
Then there will also be a method switchLine(int line) which will take the present line as input and return the line number of the next shortest available line to switch the person into and also reset the time spent to 0.
There will also be a method update(int lineNo) which will be called for every person at the end of every second to update the line number he presently is in and accordingly updates the line queues.
In the main program, the simulation will run with a while(!emptyQueue()) condition to serve all the customers.
Create new customers ar random time with each second as one iteration of the loop, check for all the customers if the time spent is more than the threshold time and then switch lines and accordingly update the customers.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.