Program 4: Pizzeria Line Simulator

Due Date and Submission Requirements


The goal of this lab is:


Background and Directions

Papa's Pizzeria is an online cooking game where players run a pizzeria, manage orders and serve customers.

In this assignment, you will write a Java program that simulates the waiting line for Papa's Pizzeria. Each person waiting in line is represented by a Customer object. You will use a queue data structure that will hold Customer objects.

Each customer has a name, their order (a single String), and the time that they entered the queue (a Long). Your Queue data structure can use a Linked List, or an Array (but using a Linked List is highly recommended).

Both regular customers and VIP customers can enter the queue. Regular customers must be added to the back of the queue, while VIP customers can cut in front of all regular customers and go to the front of the queue.

When a Customer leaves the queue, you will need to calculate how long (in seconds) they were in the queue. You also will need to keep track of the average waiting time for the queue, and the number of customers served. Additionally, you will need to calculate a review everytime a customer is served. If a customer is served within 15 seconds they will leave a 3 star (⭐⭐⭐) review, if they are served within 16 - 45 seconds they will leave a 2 star review (⭐⭐), and if they are served after 46 seconds have passed they will leave a 1 star (⭐) review.

Your program will feature a menu that prints different options (similar to Program 2), allowing the user to view, add, and remove customers from the queue.

1. View Current Queue- Shows all the current customers waiting in line. The front of the queue gets printed first, and the back of the queue gets printed last. Sample output
2. Add a regular customer to queue- Adds a new regular customer to the back of the queue. The program should ask for the name of the regular customer, their order, and then insert the Customer object into the queue.Sample output
3. Add a VIP customer to the queue - Adds a new VIP customer to the front of the queue. The VIP customer can cut in front of other regular customers, but not other VIP customers. The program should ask for the name of the VIP customer, their order, and then insert the customer object into the queue. Sample output
4. Serve next customer- Removes the customer at the front of the queue. Once the customer is removed from the queue, the program should print out how long (in seconds) that customer waited in line for (if this number is rounded up/down to the nearest integer, that is fine) and their star review. Sample output
5. Remove Customer from queue- A customer may grow inpatient, and exit the queue. The program will ask for the name of the customer that needs to be removed, and then remove them from the queue. It should print out how long they waited in line for, but this does not contribute towards the average wait time. Sample output
6. Print Queue Statistics - This methods prints out the number of customers served so far (ie the number of Customers that have been dequeued), and the average wait time of the queue. For example, suppose four customers have been served so far. Customer 1 waited 32 seconds, customer 2 waited 40 seconds, and customer 3 waited 21 seconds and customer 4 waited 16, the average wait time of the queue is (32 + 40 + 21 + 16) / 4 = 27.25 seconds. Sample output (note: in this example, 4 customers were served, and they had wait times of 44, 35, 19 and 15 seconds.)
7. Exit - this method exits the program Sample output

Restrictions

Sample Output

Your output does not need to match this exactly, but it should look pretty similar. Here is sample output after using several of the menu functions: sample output

Optional Hints

You should use a linked list to hold the Customer objects. Using an Array will be difficult since Customers in the middle of the queue can leave at any point.

I would recommend having two queues. One for regular customers, and one for VIP Customers. Adding a VIP Customer will add the VIP Customers queue (FIFO), and adding a regular customer will add the regular customers queue (FIFO). When you dequeue something, you should prioritize removing the VIP customer queue. If the VIP customer queue is empty, then you can remove something from the regular customer queue.

Tracking the time spent in the queue and calculating the average wait time will likely be the most tricky part. We will cover how to measure and calculate time in Java in class, but here is a general way of how to do so:

We get the current time (in nano seconds) when they enter the queue. When they exit the queue, we will get the current time again (in nanoseconds). To find how long they were in the queue for, we simply find the difference between these two values. You will need to convert nanoseconds to seconds ( / 1000000000)

  long start = System.nanoTime();
  // some time passes
  long end = System.nanoTime();
  long elapsedTime = end - start;
  

Grading (100 points)

Requirement Points
Your program uses a queue (Linked List or Array) to hold Customer objects. 30
Your program can print out the current customers in the queue (Menu option #1) 10
Your program can add a new regular customer to the queue correctly (Menu option #2) 10
Your Program can add a new VIP customer to the queue correctly (Menu option #3) 10
Your program dequeues the next customer correctly (Menu option #4) 10
Your program can allow a use to search for a customer in the queue by name, and remove that customer (Menu option #5)   10
Your program prints out the number of customers served, and the average wait time correctly (Menu option #6) 10
The Customer class is correctly defined 10






program 4 solution