You should show the queue contents from the first item


Queues are often used to simulate the flow of people, cars, airplanes, transactions, and so on. Write a program that models checkout lines at a supermarket, using the Queue class from the queue.java program (Listing 4.4). Several lines of customers should be displayed; you can use the display() method of Programming Project 4.1. You can add a new customer by pressing a key. You'll need to determine how the customer will decide which line to join. The checkers will take random amounts of time to process each customer (presumably depending on how many groceries the customer has). Once checked out, the customer is removed from the line. For simplicity, you can simulate the passing of time by pressing a key. Perhaps every keypress indicates the passage of one minute. (Java, of course, has more sophisticated ways to handle time.)

Project 4.1

Write a method for the Queue class in the queue.java program (Listing 4.4) that displays the contents of the queue. Note that this does not mean simply displaying the contents of the underlying array. You should show the queue contents from the first item inserted to the last, without indicating to the viewer whether the sequence is broken by wrapping around the end of the array. Be careful that one item and no items display properly, no matter where front and rear are.

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: You should show the queue contents from the first item
Reference No:- TGS01647192

Expected delivery within 24 Hours