1. Coffee Shop

  • Worth: 5%

  • DUE: February 1st, 2024 at 11:55pm; submitted on MOODLE.

Warning

This is an individual assignment.

1.1. 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:

// Student name:
// Student number:

1.2. 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

1.3. Architecture of the program

  • You will need a class 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 Queue that will be the regular queue.

  • A class PriorityMin that will implement a min priority queue (minheap) to prioritize the regular coffee customers.

  • A class PriorityMax that will implement a max priority queue (maxheap) to prioritize the special coffee customers.

  • A class Customer that will represent a customer.

  • A file main.java.

1.4. Customer

  • This class is simple and contains the following variables:

    • type: 1 or 2, 1 for regular coffee and 2 for special coffee.

    • serviceTime that represents the service time of this customer.

    • price the price related to the type of customer.

1.5. 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.

1.6. Queues

Important

Each of the following queues needs to be implemented as generic classes.

1.6.1. PriorityMin

  • It is a regular binary heap, but the lowest is type the higher is the priority.

1.6.2. PriorityMax

  • It is a regular binary heap, but the higher is type the higher is the priority.

1.6.3. Queue

  • It is a regular queue: FIFO.

1.7. 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.