********** Coffee Shop ********** * **Worth**: 5% * **DUE**: February 6th, 2022 at **11:55pm**; submitted on MOODLE. .. warning:: This is an individual assignment. How to submit your work ======================= You need to submit your Java files directly on moodle. The first two lines of the Java files should be as follows: .. code-block:: java // Student name: // Student number: Instructions ============ * In this assignment you will compare the efficiency of priority queues. * We will consider a coffee shop scenario with customers arriving and ordering different types of coffee. * You can put the drinks in two categories: * Regular coffees * Special coffees * Regular coffees cost less, but are faster to serve. * While special coffees cost more, but are longer to serve. * The purpose is to verify how the coffee shop can earn more just by implementing three types of queues: * Regular queues, so no priority: first arrived first served. * Priority to regular coffees. * Priority to special coffees. * To evaluate the most efficient queue: * You will simulate 1000 services for each queue. * A service last 60 minutes. * The coffee shop have a maximum size of 20 customers. * When it is full, no new customers can be added to queue. * The probability that a new customer arrives every 30 seconds (time step) is 55%. * The type of clients/drinks generated follow the probabilities: * Regular coffee: 70% * Special coffee: 30% * The service for each type of coffee follows a uniform distribution in the following range: * Regular coffee: 60s - 120s (so between [2 - 4] time steps) * Special coffee: 120s - 300s (so between [4 - 10] time steps) * The price of the drinks are as follows: * Regular coffee: $2 * Special coffee: $5 Architecture of the program =========================== * You will need a class :code:`Simulator` that will simulate the 1000 services and calculate the earning of the coffee shop for each type of queue. * You will need a class :code:`Queue` that will be the regular queue. * A class :code:`PriorityMin` that will implement a min priority queue (minheap) to prioritize the regular coffee customers. * A class :code:`PriorityMax` that will implement a max priority queue (maxheap) to prioritize the special coffee customers. * A class :code:`Customer` that will represent a customer. * A file :code:`main.java`. Customer ======== * This class is simple and contains the following variables: * :code:`type`: 1 or 2, 1 for regular coffee and 2 for special coffee. * :code:`serviceTime` that represents the service time of this customer. * :code:`price` the price related to the type of customer. Simulator ========= * This class is the most complicated one. * it will have a method to generate a customer based on the previous probabilities. * It will have a method to simulate one service: * You will have a time step (one iteration) of 30s. * Each time step, you will check if a new customer is generated: * You will generate the type of customer. * You will generate the service time of the customer. * When you service a customer you remove it from the queue. * But you need to finish servicing the customer to start servicing the next one. * When you are servicing the customer you can remove 30s from the service time after each iteration. * You add the price of the coffee to the total of the service. * At the end of the service (60 min) you add the earning of the service to the total of all services for this type of queue. * It will also have a method to simulate the 1000 services. * You will implement a method that simulate all the services for each type of queues and print the average earnings per service. Queues ====== .. important:: Each of the following queues needs to be implemented as generic classes. PriorityMin ----------- * It is a regular binary heap, but the lowest is type the higher is the priority. PriorityMax ----------- * It is a regular binary heap, but the higher is type the higher is the priority. Queue ----- * It is a regular queue: FIFO. Some marking details ==================== .. warning:: Having the correct outputs doesn't mean that you will obtain a perfect mark. The marking will depend on: * Correctness. * Comments * Variable names * Style * etc.