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; } } }
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; } }
public void CheckInBook(Person2 p) { p.ReturnBook(); }
public void HandleBookRequest(Person2 p, string bookName) { Book2 b = bookList.Find(bk => bk.Title == bookName); p.RequestBook(b); }
public void AddUser(Person2 p) { users.Add(p); }
public override bool Equals(object obj) { Person2 p = obj as Person2; return(!(p == null || p.ID != this.ID)); }