예제 #1
0
파일: POS.cs 프로젝트: mossi1mj/LibraryApp
        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;
                        }
                    }
                }
            }
        }
예제 #2
0
 public void AddBook(Book aBook)
 {
     Books.Add(aBook);
 }