コード例 #1
0
        public void NotifyObservers()
        {
            if (WaitList.Count > 0)
            {
                Queue <Person2> temp = new Queue <Person2>();
                while (WaitList.Count > 0)
                {
                    Person2 nextInLine = WaitList.Dequeue();
                    if (!nextInLine.HasBook)
                    {
                        nextInLine.Update();
                        RemoveObserver(nextInLine);
                        break;
                    }
                    else
                    {
                        temp.Enqueue(nextInLine);
                    }
                }

                if (temp.Count > 0)
                {
                    while (WaitList.Count > 0)
                    {
                        temp.Enqueue(WaitList.Dequeue());
                    }
                    WaitList = temp;
                }
            }
        }