Exemple #1
0
        public void ExecuteMainMenuChoice(MenuOptions choice, List <Book> bookList)
        {
            searchResults = new List <Book>();
            switch (choice)
            {
            case MenuOptions.DisplayAll:
                Console.Clear();
                Menu.DisplayBookList(bookList);
                searchResults = bookList;
                LibraryMember.SelectFromList(searchResults, cart);
                appRunning = true;
                return;

            case MenuOptions.SearchByAuthor:
                Console.Clear();
                searchResults = LibraryMember.MemberSearchByAuthor(bookList);
                LibraryMember.SelectFromList(searchResults, cart);
                appRunning = true;
                return;

            case MenuOptions.SearchByTitle:
                Console.Clear();
                searchResults = LibraryMember.MemberSearchByTitle(bookList);
                LibraryMember.SelectFromList(searchResults, cart);
                appRunning = true;
                return;

            case MenuOptions.GoToCart:
                Console.Clear();
                Cart.BringUpCart(cart);
                appRunning = true;
                SaveLoad.Save(bookList);
                return;

            case MenuOptions.ManageLibrary:
                Console.Clear();
                AddRemove.ManageLibrary(bookList);
                appRunning = true;
                SaveLoad.Save(bookList);
                return;

            case MenuOptions.Quit:
                appRunning = false;
                SaveLoad.Save(bookList);
                return;

            default: return;
            }
        }
Exemple #2
0
        public void StartApp()
        {
            var search = new Search();

            List <Book> books = new List <Book>
            {
                new Book("20 Love Poems and a Song of Despair", "Pablo Neruda", true, new DateTime()),
                new Book("1984", "Geogre Orwell", false, new DateTime(2019, 9, 30)),
                new Book("The Art of War", "Sun Tsu", false, new DateTime(2019, 8, 25)),
                new Book("48 Laws of Power", "Robert Greene", true, new DateTime()),
                new Book("Moby Dick", "Herman Melville", true, new DateTime()),
                new Book("War and Peace", "Leo Tolstoy", false, new DateTime(2019, 8, 28)),
                new Book("Hamlet", "william Shakespare", true, new DateTime()),
                new Book("Heart of Darkness", "Joseph Conrad", true, new DateTime()),
                new Book("Invisible Man", "Ralah Ellison", false, new DateTime(2019, 12, 1)),
                new Book("To Kill a Mockingbird", "Harper Lee", true, new DateTime()),
                new Book("As I Lay Dying", "William Faulkner", true, new DateTime()),
                new Book("The Lord of the Rings", "J.R.R. Tolkien", true, new DateTime())
            };


            var results = search.SearchByTitle(Console.ReadLine(), books);

            foreach (var item in results)
            {
                Console.WriteLine($"{item.Author}, {item.Title}");
            }


            MenuOptions choice = LibraryMember.GetMenuSelection();

            switch (choice)
            {
            case 1:
                return;


            default:
                break;
            }
        }
Exemple #3
0
        public static void RemoveBook(List <Book> books)
        {
            Console.Clear();
            Console.WriteLine("How do you want to find a book to remove?");
            Console.WriteLine("1. Display all books");
            Console.WriteLine("2. Search by author");
            Console.WriteLine("3. Search by title");
            Book        selectedBook = new Book("title", "author", false);
            List <Book> searchResults;
            bool        isValidRenameOption = false;

            do
            {
                switch (Console.ReadLine().ToLower())
                {
                case "one":
                case "1":
                    Console.Clear();
                    Console.WriteLine("Select a book to remove.");
                    Menu.DisplayBookList(books);
                    selectedBook        = LibraryMember.SelectBook(books);
                    isValidRenameOption = true;
                    break;

                case "two":
                case "2":
                    Console.Clear();
                    Console.WriteLine("Search an author and select a book to remove.");
                    searchResults = LibraryMember.MemberSearchByAuthor(books);
                    if (searchResults.Count == 0)
                    {
                        return;
                    }
                    selectedBook        = LibraryMember.SelectBook(searchResults);
                    isValidRenameOption = true;
                    break;

                case "three":
                case "3":
                    Console.Clear();
                    Console.WriteLine("Search a title and select a book to remove.");
                    selectedBook        = LibraryMember.SelectBook(LibraryMember.MemberSearchByTitle(books));
                    isValidRenameOption = true;
                    break;

                default:
                    Console.WriteLine("That is not a valid entry. Please try again:");
                    isValidRenameOption = false;
                    break;
                }
            } while (!isValidRenameOption);


            Console.WriteLine($"Are you sure you want to remove {selectedBook.Title} from the library? [Y/N]");
            bool validInput = false;

            do
            {
                string userInput = Console.ReadLine();
                if ((userInput.Equals("Y", StringComparison.OrdinalIgnoreCase)))
                {
                    books.Remove(selectedBook);
                    validInput = true;
                }
                else if ((userInput.Equals("N", StringComparison.OrdinalIgnoreCase)))
                {
                    return;
                }
                else
                {
                    Console.WriteLine("Not a valid input, try again.");
                    validInput = false;
                }
            } while(!validInput);

            Console.WriteLine($"You've removed {selectedBook.Title} from the library.");
            Console.WriteLine("Press enter to continue");
            Console.ReadLine();
        }
Exemple #4
0
        public void StartApp()
        {
            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.Green;

            try
            {
                for (int i = 1; i < 40; i++)
                {
                    Console.SetWindowSize(110, i);
                    System.Threading.Thread.Sleep(10);
                }
            }
            catch { }

            search   = new Search();
            bookList = SaveLoad.Load();
            SaveLoad.Save(bookList);
            searchResults = new List <Book>();
            cart          = new List <Book>();
            appRunning    = false;

            #region INTRO

            Console.WriteLine(@"  ___  ____   __   __ _  ____     ___  __  ____   ___  _  _  ____    __    __  ____  ____   __   ____  _  _");
            Console.WriteLine(@" / __)(  _ \ / _\ (  ( \(    \   / __)(  )(  _ \ / __)/ )( \/ ___)  (  )  (  )(  _ \(  _ \ / _\ (  _ \( \/ )");
            Console.WriteLine(@"( (_ \ )   //    \/    / ) D (  ( (__  )(  )   /( (__ ) \/ (\___ \  / (_/\ )(  ) _ ( )   //    \ )   / )  / ");
            Console.WriteLine(@" \___/(__\_)\_/\_/\_)__)(____/   \___)(__)(__\_) \___)\____/(____/  \____/(__)(____/(__\_)\_/\_/(__\_)(__/  ");
            Console.WriteLine("       ");

            Console.WriteLine(@"                          ____________________________________________________");
            Console.WriteLine(@"                         |____________________________________________________|");
            Console.WriteLine(@"                         | __     __   ____   ___ ||  ____    ____     _  __  |");
            Console.WriteLine(@"                         ||  |__ |--|_| || |_|   |||_|**|*|__|+|V||___|N||  | |");
            Console.WriteLine(@"                         ||==|^^||--| |=||=| |=*=||| |~~|~|  |=|L|| | |I||==| |");
            Console.WriteLine(@"                         ||  |##||  | | || | |ED |||-|  | |==|+|A||-|-|C||__| |");
            Console.WriteLine(@"                         ||__|__||__|_|_||_|_|___|||_|__|_|__|_|D||_|_|K||__|_|");
            Console.WriteLine(@"                         ||_______________________||__________________________|");
            Console.WriteLine(@"                         | _____________________  ||      __   __  _  __    _ |");
            Console.WriteLine(@"                         ||=|=|=|=|=====|=|=|=|=| __..\/ |  |_|  ||#||==|  / /|");
            Console.WriteLine(@"                         || | | | |OLLIE| | | | |/\ \  \\|++|=|  || ||==| / / |");
            Console.WriteLine(@"                         ||_|_|_|_|_____|_|_|_|_/_/\_.___\__|_|__||_||__|/_/__|");
            Console.WriteLine(@"                         |____________________ /\~()/()~//\ __________________|");
            Console.WriteLine(@"                         | __   __    _  _     \_  (_ .  _/ _      _     _____|");
            Console.WriteLine(@"                         ||~~|_|..|__| || |_ _   \ //\\ /  |=|_  /) |___| | | |");
            Console.WriteLine(@"                         ||--|+|^^|==|1||2| | |__/\ __ /\__| |(\/((\ +|+|=|=|=|");
            Console.WriteLine(@"                         ||__|_|__|__|_||_|_| /  \ \  / /  \_|_\___/|_|_|_|_|_|");
            Console.WriteLine(@"                         |_________________ _/    \/\/\/    \_ /   /__________|");
            Console.WriteLine(@"                         | _____   _   __  |/      \../      \/   /   __   ___|");
            Console.WriteLine(@"                         ||_____|_| |_|##|_||   |   \/ __\       /=|_|++|_|-|||");
            Console.WriteLine(@"                         ||_____|_|=|#|--| |\   \   o     \_____/  |~|  | | |||");
            Console.WriteLine(@"                         ||_____|_|_|_|__|_|_\   \  o     | |_|_|__|_|__|_|_|||");
            Console.WriteLine(@"                         |_________ __________\___\_______|____________ ______|");
            Console.WriteLine(@"                         |__    _  /    ________     ______           /| _ _ _|");
            Console.WriteLine(@"                         |\ \  |=|/   //    /| //   /  /  / |        / ||%|%|%|");
            Console.WriteLine(@"                         | \/\ |*/  .//____// //   /__/__/ (_)      /  ||=|=|=|");
            Console.WriteLine(@"                         |  \/\|/   /(____|/ //                    /  /||~|~|~|");
            Console.WriteLine(@"                         | ___\_/   /________//   ________         /  /||_|_|_|");
            Console.WriteLine(@"                         | ___ /   (|________/  |\_______\       /  /| |______|");
            Console.WriteLine(@"                         |____/_________________\|________)_____/__/_|_|______|");
            Console.WriteLine("");
            Console.WriteLine("");
            #endregion

            Console.WriteLine("Press enter to continue");
            Console.ReadLine();

            do
            {
                Console.Clear();
                SaveLoad.Save(bookList);
                bookList = SaveLoad.Load();
                MenuOptions choice = LibraryMember.GetMenuSelection();
                ExecuteMainMenuChoice(choice, bookList);
            } while (appRunning);
        }