nus-cs2030 / 2122-s2

CS2030 repository and wiki for AY 2021/2022 Sem 2
MIT License
0 stars 0 forks source link

Level 3 of Project #138

Open hengyjj opened 2 years ago

hengyjj commented 2 years ago

Summary

Put a summary of the question

Description

Hello! After reading Level 3 of the Project, I am really unsure of what are we supposed to do. Are we supposed to create different classes for different events such as Arrive, Serve, Done, Wait and Leave. Each class is supposed to implement Event?

I am confused at the part where the instruction says

"Using an ARRIVE event at time t as an example, if the execute method takes in a shop with all servers free, then the shop will return a serve event (to be served by 1 at time t), and the shop (no updates are necessary since service has not started). On the other hand, if the event was a SERVE event at time t at i, then the execute method takes in the shop, and returns a DONE event at time t + 1.0 (assuming service time of 1.0) together with the updated shop with server i tagged as busy."

Does it mean there is a status assigned for each server? Also, if I am currently at Arrive, so when a customer walks in, the execute method should return an Optional<Serve>? While indicating that the first server in line will have his status changes from "Free" to "Busy"?

Appreciate any help and thank you!

Screenshots (if any):

Insert Images here if necessary

mingshan2705 commented 2 years ago

Yup, you would have to update the server with each different event. Then the shop containing the servers would have to be updated as well. Other than "Free" and "Busy", you might also want to include if the server is available for waiting (executes Wait event) or not (executes Leave event). Hope this helps!

hengyjj commented 2 years ago

Yup, you would have to update the server with each different event. Then the shop containing the servers would have to be updated as well. Other than "Free" and "Busy", you might also want to include if the server is available for waiting (executes Wait event) or not (executes Leave event). Hope this helps!

Thank you Ming Shan for your reply! Just wish to clarify, by updating the shop containing the servers, does it mean updating the list of servers that reside within the Shop class? (E.g. Server 1 is busy, Server 2 is available etc) With each individual server in the Server list containing their each status too?

Thank you!

mingshan2705 commented 2 years ago

Yeap, you have to update the list of servers that reside within the Shop class because the execute method takes in a Shop and returns an updated Shop in Pair<Optional, Shop).

baymaxtdx97 commented 2 years ago

Adding Server as a property to some of the events will help to make things easier for you as well.

Zhenyubbx commented 2 years ago

To add on, you will just need to create the different event classes using the eventstub as a template and change the execute method accordingly to suit the appropriate needs for each class. Based on my own interpretation, I think the purpose of returning the eventstub is for testing purposes. This is so that you won't have to create all the different events at once in order to test just one particular event.

aaronfyr commented 2 years ago

Hi, does your Server store the Customer that he is serving? (Has a private final Customer customer variable)

hengyjj commented 2 years ago

Hi, does your Server store the Customer that he is serving? (Has a private final Customer customer variable)

Hello. To answer your question, my server does store the customer that he is serving. However, I stored it as an Optional because there will be instances where I need to update the Server class while being inside the Event classes by stating that a customer has been served and will store inside that optional, else it will return Optional. empty() to indicate that customer has been served and its free to serve again.