Lab 9: Queues

Due Date and Submission Requirements


The goal of this lab is:


Directions

You will be writing a Java program that simulates cars using a Car Wash station. Using Lab9Demo.java as a starting point, you will define the CarQueue class and fill in the missing methods for the queue data structure.


Since you are writing a queue that represents a Car wash, each car object will have: You will need to define the Car class, and add any necessary methods. At the very least, you will need to override the toString() method so that it returns information about the customer/car. The string that should be returned should follow the format: <Car Type> (<Car Owner>)

Next, you will define the CarQueue class, which will be your queue. You should use a LinkedList. The queue has a finite size, and that size is specified as an argument to the CarQueue constructor. Your queue will need to keep track of the current size of the queue and the capacity of the queue. You will also need to keep track of the number of cars serviced by the car wash, and how much money the car wash has made.

There is a special priority that this car wash must follow. VIP customers are allowed to cut in front of non-VIP customers, but they cannot cut in front of other VIP members. Please see the "hints" section below to understand how to implement this priority. This queue is a hybrid of a priority queue and a vanilla queue.


You are NOT allowed to modify the Lab9Demo class. After creating the CarQueue class, you must define the following methods:

Starting Code

Output

When you run your program, your output should look exactly like this screenshot

Restrictions

You CANNOT import java.util.Queue; (i know this is silly)

Hints

Implementing the priority logic for handling VIP customers is probably the trickiest part. I strongly encourage you to follow this hint:
For your CarQueue class, consider having two queues (two LinkedList), one for VIP customers (vip_queue), and one for normal Customers (normal_queue). When adding a new car, check their VIP status. If they are a VIP, add them to the back of vip_queue. If they are a normal customer, add them to the back of normal_queue.
When dequeueing and peeking, always prioritize the vip_queue. If vip_queue is empty, then use the element at the front of the normal_queue. When printing the queue, you first print out the vip_queue (if it's not empty), and then print out the normal_queue (if it's not empty)

Grading (10 points)