Open hengyjj opened 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!
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!
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
Adding Server as a property to some of the events will help to make things easier for you as well.
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.
Hi, does your Server store the Customer that he is serving? (Has a private final Customer customer variable)
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
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 anOptional<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