nus-cs2030 / 2021-s1

27 stars 48 forks source link

Project 2 Level 4_2 #583

Open edwin716 opened 3 years ago

edwin716 commented 3 years ago

Description

Hi, I'm facing this issue whereby the customer leaves instead of waiting. I believe it has to be smth wrong with my ArriveEvent but can't seem to find the issue. Would appreciate any inputs thanks!

Screenshots (if any):

image image

jiayi-lim commented 3 years ago

What is your getstatus()! How do you decide the value of the status? Seems like your canQueue is wrong.

fionacheong commented 3 years ago

hi, the problem could be your implementation of maximum queue length? because the server 3 should have a queue length of more than 1 which would allow both customers 2 and 3 the queue at the same time, but for yours after customer 2 joins the queue, customer 3 can no longer join and hence leaves instead!

fionacheong commented 3 years ago

actually if your canQueue is correct i don't think you would need the hasNoWaitingCustomer condition anymore

frisciliasultan commented 3 years ago

May be you can try printing out the Servers in the Shop and their queue (how many people / who is queueing). Then from there you can trace back what went wrong. it could be the find method/ the getStatus() method

itmeruoxin commented 3 years ago

yup, like what someone else suggested canQueue should be able to cover hasNoWaitingCustomer. printing out the servers and their queue lengths will help a lot in tracing! you might be updating the servers wrongly such that it doesn't find anything that canQueue

markmcwong commented 3 years ago

One other point you can look at would be the way you implement WaitEvent and whether you made sure you have actually added Customer 2 into the queue so that when you do y.getQueueLength() the changes is reflected