public void GiveRequestedBook() { if (HasBook) { throw new Exception($"{this} already has a book!"); } if (RequestedBook == null) { throw new Exception($"{this} does not have a book requested."); } //Else, the book is good to go Console.WriteLine($"{this} has gotten their requested book, {RequestedBook}."); CheckedOutBook = RequestedBook; RequestedBook = null; }
public void ReturnBook() { if (!HasBook) { throw new Exception($"{this} cannot return this book because they do not have a book!"); } //Else, return the book Console.WriteLine($"{this} has returned {CheckedOutBook}."); CheckedOutBook.CheckIn(); CheckedOutBook = null; if (RequestedBook != null) { GiveRequestedBook(); } }
public void RequestBook(Book2 bk) { if (!HasBook && bk.IsAvailable) { CheckOutBook(bk); } else if (RequestedBook == null) { Console.WriteLine($"{Name} has requested {bk}."); bk.RegisterObserver(this); RequestedBook = bk; } else { throw new Exception("Person cannot have more than one book requested."); } }
public void CheckOutBook(Book2 bk) { bk.CheckOut(); }
public void HandleBookRequest(Person2 p, string bookName) { Book2 b = bookList.Find(bk => bk.Title == bookName); p.RequestBook(b); }
public bool CheckAvailability(Book2 b) { return(b.IsAvailable); }
public void AddBook(Book2 b) { bookList.Add(b); }
private void CheckOutBook(Book2 bk) { Console.WriteLine($"{this} has checked out {bk}."); bk.CheckOut(); CheckedOutBook = bk; }