Open Shandon96 opened 3 years ago
in your ServeEvent, you'll need to get the updated Server from the shop by using shop.find()
I think it would be better if you handled the checking of availability of server in ServeEvent instead, as your event classes can only have one method (the toString() method) as specified by the project requirement. For the function in the ServeEvent constructor, check if the server is available using shop.find(x -> x.getIdentifier() == server.getIdentifier()).get().isAvailable(). If it is available, then proceed to return a pair of updated shop and DoneEvent. If it is not available, return a pair of the shop and a new ServeEvent with the updated time when the server is next available. Hope this helps!
Thanks @shhiiiqqqqiiiii and @goatygoatygoat! I've finally solved it after so many excruciating days! Hope the rest of the project will be doable for me. All the best for your finals tmr! :)
Description
Hi guys, I am having issues with project 2 level 5, in that my server does not seem to be updated correctly (1st pic). In my Simulator queue, I check if the server in the current updated shop is available being going ahead with ServeEvent (2nd pic). In my ServeEvent class, I check if it came from ArriveEvent, and add one to the queueLength if that is so, or else I leave the queueLength as it is (3rd pic). I have spent many days on this level and still can't figure out the problem, so I will greatly appreciate any help!
Topic:
Specific Topics this question is related to (If Any)
Screenshots (if any):