Exemple #1
0
        private static void MainMenu()
        {
            bool continueProgram = true;

            while (continueProgram)
            {
                Options();
                string userChoice = Validator.OptionChoice();

                if (userChoice.ToLower() == "quit" || userChoice == "4")
                {
                    SaveCurrentInventory();
                    continueProgram = false;
                }
                else if (userChoice == "1")
                {
                    DisplayCurrentInventory();
                }
                else if (userChoice == "2")
                {
                    while (true)
                    {
                        Console.WriteLine("Search the Book you want to Check Out:");
                        string input     = Console.ReadLine();
                        Book   foundBook = SearchLibrary(currentInventory, input);
                        if (foundBook != null)
                        {
                            Console.WriteLine($"Found {foundBook.Title}");
                            if (foundBook.Status == true)
                            {
                                foundBook.Status = false;
                                Console.WriteLine($"{foundBook.Title} is now Checked Out!");
                                Console.WriteLine($"Please return this book by {GetCheckOutDate()}");
                            }
                            else
                            {
                                Console.WriteLine("This book is already Checked Out!");
                            }
                            SaveCurrentInventory();
                            break;
                        }
                    }
                }
                else if (userChoice == "3")
                {
                    while (true)
                    {
                        Console.WriteLine("Which Book do you want to Check In: ");
                        DisplayAvailableInventory();
                        string input     = Console.ReadLine();
                        Book   foundBook = SearchLibrary(currentInventory, input);
                        if (foundBook != null)
                        {
                            if (foundBook.Status == false)
                            {
                                foundBook.Status = true;
                                Console.WriteLine($"{foundBook.Title} is now Checked In!");
                            }
                            else
                            {
                                Console.WriteLine("This book is already Checked In!");
                            }
                            SaveCurrentInventory();
                            break;
                        }
                    }
                }
            }
        }
Exemple #2
0
 public void AddBook(Book aBook)
 {
     Books.Add(aBook);
 }