Open lihuicham opened 2 years ago
Hi! You can create a SelfCheck class that extends your existing server class. Also, you can consider having an ImList in your Simulate8 class that acts as the shared queue, which was suggested in this issue!
This was what I did
I used a similar approach as @Geraldworks except for point 5. Once a self checkout is done, it will just serve the next customer in the shared customer queue. Remember to update all self checkout queues when you serve a customer as well.
Hii! My approach was different from the above comments as I did not have a new SelfCheck class. I added a boolean constructor inside my Server class to distinguish SelfChecks from normal servers and whenever a SelfCheck's queue is updated, I update the shop so that all other SelfChecks' queues are updated accordingly as well. I also changed the Server class's toString() to fulfil the required formant of printing SelfCheck servers. So technically all of my servers are still of the same Server class and imo this might be more convenient. Hope it helps!
hello! whether or not you choose to implement it as an interface or superclass is up to you and whatever way you choose will probably be able to work:-) BUT to address your 4th question, no you can't use a static variable for the shared queue because for this mod all variables are declared private final and since static attributes are the same across the entire class, there's no way to change it later.
all the methods mentioned by everyone above work! but i took a bit of a different approach which i felt modelled the question more closely: since the question said that "customers are always waiting at counter k + 1 even though they may be served by other counters later" what i did was to have the first counter have the same qMax as the human servers but all the subsequent counters have a qMax of 0! and then once i get to the wait event, if it is in the shared queue, i'll redirect the customer to the next free counter instead when scheduling the serve event! all the best!!
Hi, can someone kindly explain on how you approach level 8 ?
Should we implement a Server interface and have a HumanServer class and SelfCheckOut class, both implements the Server interface ?
Or, should the Server be a superclass instead of interface ?
Also, when the question said that all self check out counters share the same queue, does that mean that we will need a static customer queue in the self check out class, right ?
Can someone kindly explain on your thought process in approaching this level and what should I look out for when doing this level ? Thank you in advance !