public void AddBook(Book book) { if (book.Available) { AvailableBooks.Add(book); } else { CheckedOutBooks.Add(book); } }
// RETURN BOOK public void ReturnBook(string selection) { Book selectedBook = ValidateBook(CheckedOut, selection); if (selectedBook == null) { Console.WriteLine(" Invalid Selection"); return; } else { selectedBook.Available = true; AvailableBooks.Add(selectedBook); CheckedOut.Remove(selectedBook); Console.Clear(); Console.WriteLine(" Book Returned!"); } }
public void ReturnBook(string input) { Book selectedBook = ValidateBook(input, CheckedOutBooks); if (selectedBook == null) { Console.Clear(); System.Console.WriteLine("Invalid Selection... Press enter to continue"); Console.ReadLine(); return; } //set available to false, add book to checked out and remove from available array selectedBook.Available = true; AvailableBooks.Add(selectedBook); CheckedOutBooks.Remove(selectedBook); Console.Clear(); System.Console.WriteLine($"Thanks for returning {selectedBook.Title}!"); }
public void ReturnBook(string selection) { Book selectedBook = ValidateBook(selection, CheckedOut); if (selectedBook == null || selectedBook.Available == true) { Console.Clear(); System.Console.WriteLine(@"Invalid Selection"); return; } else { selectedBook.Available = true; AvailableBooks.Add(selectedBook); CheckedOut.Remove(selectedBook); System.Console.WriteLine("Congrats my Dude, Book is back"); } }
public void ReturnBook(string selection) { //checkout book Book selectedBook = ValidateUserSelection(selection, CheckedOut); if (selectedBook == null) { System.Console.WriteLine(@"Invalid Selection, please make a valid selection: 1 "); return; } selectedBook.Available = true; AvailableBooks.Add(selectedBook); CheckedOut.Remove(selectedBook); Console.Clear(); System.Console.WriteLine("Successfully Returned Book!"); }
public void ReturnBook() { System.Console.WriteLine("Enter the number of the book you'd like to return."); ViewBooks(CheckedOutBooks); Book bookToReturn = ValidateUserInput(CheckedOutBooks); // null check to prevent breaking errors if (bookToReturn == null) { return; } // if found a book to return then: // 1. reassign the available property to true // 2. remove the book from the checkoutbooks list // 3. add the book to the availablebooks list bookToReturn.Available = true; CheckedOutBooks.Remove(bookToReturn); AvailableBooks.Add(bookToReturn); System.Console.WriteLine("Thanks for returning {0}!", bookToReturn.Title); }
public bool AddNewBook(Book book, double price, int quantity = 1) { var validationService = _dependencyService.Get <IValidationService>(); if (validationService.isValidBook(book) && validationService.IsValidPrice(price) && validationService.IsValidQuantity(quantity)) { var searchedIndex = AvailableBooks.FindIndex(item => item.Book.ISBN == book.ISBN); if (searchedIndex == -1) { AvailableBooks.Add(new BookProductInfo { Book = book, BorrowPrice = price, Quantity = quantity }); return(true); } } return(false); }
public void AddBook(Book book) { AvailableBooks.Add(book); }
internal void addBook(Book book) { AvailableBooks.Add(book); }