コード例 #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;
                }
            }
        }
コード例 #2
0
        public void RemoveObserver(object person)
        {
            Queue <Person2> temp = new Queue <Person2>();
            Person2         p    = person as Person2;

            while (WaitList.Count > 0 && p != null)
            {
                Person2 next = WaitList.Dequeue();
                if (next.Equals(p))
                {
                    break;
                }
                else
                {
                    temp.Enqueue(p);
                }
            }

            if (temp.Count > 0)
            {
                while (WaitList.Count > 0)
                {
                    temp.Enqueue(WaitList.Dequeue());
                }
                WaitList = temp;
            }
        }
コード例 #3
0
 public void CheckInBook(Person2 p)
 {
     p.ReturnBook();
 }
コード例 #4
0
        public void HandleBookRequest(Person2 p, string bookName)
        {
            Book2 b = bookList.Find(bk => bk.Title == bookName);

            p.RequestBook(b);
        }
コード例 #5
0
 public void AddUser(Person2 p)
 {
     users.Add(p);
 }
コード例 #6
0
ファイル: Person2.cs プロジェクト: njrogie/sse662_proj3
        public override bool Equals(object obj)
        {
            Person2 p = obj as Person2;

            return(!(p == null || p.ID != this.ID));
        }