nus-cs2030 / 2122-s2

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

Project level 6 confused #352

Open jlee1007 opened 2 years ago

jlee1007 commented 2 years ago

Hi all for project level 6 we are suppose to allow for >1 customers to queue. all the methods I've tried seem to require me to invoke .get() even way before the earlier customers have been served which spoils the timing for them too.

does anyone know how to circumvent this problem? or what should be the correct way to update the nextAvailTime of the server?

thank you!

wk1267 commented 2 years ago

HI, u shd only call .get once, which shd be when u r serving them

YangHaoying commented 2 years ago

Hi! You should stick to principles in level 5 which is only to call .get() once for every customer in their ServeEvent. An approach would be to only return actual ServeEvent for a waiting customer if it is at the top of their queue, and some PendingEvent class if not. Then you should need to get the service time only once, as now the customer only has one actual ServeEvent.

yjjjiajie commented 2 years ago

for me, i invoked the .get() in my simulate, which ensures that I only get the timing when i rly need to serve

jlee1007 commented 2 years ago

@YangHaoying thanks! how did u update the timing for the pending event tho

loqir commented 2 years ago

@YangHaoying thanks! how did u update the timing for the pending event tho

yeah i was thinking the same thing too! i wonder if it's possible to track the customer that the server is currently serving and then add this servicetime to the current time to update the timing for the pending event, maybe through an attribute in the Server class, otherwise my pending event keeps calling itself recursively

Edit : in the serve class, after i got the servicetime, i passed it into server's constructor so that i could access the servicetime of the customer that is currently being served

abigailxj commented 2 years ago

@loqir hello, how did you update the servers for the pending events such that the service times are updated? since pending events are created before the first person in queue gets served

loqir commented 2 years ago

@abigailxj hello! in my pending event, i did not update the server. i first checked if the customer was the first in the waiting list. if so, i will return a serve event. else, i will return another pending event which event time included the service time of the server.