A couple of days back, I wrote code that walked through the seats list and found any empty seats. It then went to get a user to fill the empty seat, if possible.
Today, I did the same for the users – that is, I wrote code that goes through the user list and removes any user that have abandoned waiting.
Here's the code in the DataUser class:
public bool hasAbandoned(int x)
{
if (x [GREATERTHAN] (queueUpTime + patienceTime)) return true;
return false;
}
This compares the current tick to the time the user is willing to wait plus the time when the user started waiting.
Here's the code in Simulation that checks this and, if necessary, removes the object from the list:
foreach (DataUser d in computerQueue)
{
if (d.hasAbandoned(simTick)) computerQueue.Remove(d);
}
I haven't been writing many tests lately. I want to get the thing running and then refine it. After all the pieces are there (hopefully by the end of the week), I want to spend some time cleaning it up and documenting it.
No comments:
Post a Comment