public void DisplayTitle() { BookListView listView = new BookListView(bookDb); int count = 0; string response = Console.ReadLine(); Console.WriteLine("Here are all our books that share that title:"); foreach (Book b in bookDb) { if (b.Title.ToLower().Contains(response.ToLower())) { listView.DisplayTitle(b.Title); } else { count++; } } if (count == bookDb.Count) { Console.Clear(); Console.WriteLine($"Oops! Sorry, it looks like we could not find \"{response}\" in our records of books"); } else { CheckOut(); } }
public void DisplayAllTitle() { BookListView listView = new BookListView(bookDb); foreach (Book b in bookDb) { listView.DisplayTitle(b.Title); } }
public void DisplayAuthor() { int count = 0; BookController bControl = new BookController(); BookListView listView = new BookListView(bookDb); List <string> authors = new List <string>(); foreach (Book b in bookDb) { if (!authors.Contains(b.Author)) { authors.Add(b.Author); } } foreach (string author in authors) { DisplayMenuWithBorder(author); } DisplayBorder(); Console.Write("\nBased on this list, is there an author whose books you'd like to see if we have? (y/n): "); string response = Console.ReadLine().ToLower(); if (response == "y") { Console.Write("Please enter your desired Author: "); string authorChoice = Console.ReadLine().ToLower(); Console.Clear(); Console.WriteLine($"Here are all our books by {authorChoice}:"); DisplayCenterBorder(); foreach (Book b in bookDb) { if (b.Author.ToLower().Contains(authorChoice)) { bControl.BookAction(b); } else { count++; } } DisplayCenterBorder(); if (count == bookDb.Count) { Console.Clear(); Console.WriteLine($"Oops! Sorry, it looks like we do not have any books by \"{authorChoice}\". "); } else { CheckOut(); } } }
public void WelcomeAction() { string response = "yes"; #region From Txt file to string Array string[] Titles = File.ReadAllLines(@"C:\BookLibrary\Books.txt"); string[] Authors = File.ReadAllLines(@"C:\BookLibrary\Author.txt"); string[] Types = File.ReadAllLines(@"C:\BookLibrary\Genre.txt"); #endregion #region From Txt file to DateTime Array string[] Dates = File.ReadAllLines(@"C:\BookLibrary\DateTime.txt"); DateTime[] dueDates = new DateTime[Dates.Length]; for (int i = 0; i < Dates.Length; i++) { if (Dates[i] == "DateTime.Now" || DateTime.Compare(DateTime.Now.Date, DateTime.Parse(Dates[i])) > 0) //To stay dynamic with Text File in case of books being checked out. { dueDates[i] = DateTime.Now.Date; } else { dueDates[i] = DateTime.Parse(Dates[i]).Date; } } #endregion #region From Txt file to bool Array string[] checkedOut = File.ReadAllLines(@"C:\BookLibrary\Status.txt"); bool[] statuses = new bool[checkedOut.Length]; for (int i = 0; i < Dates.Length; i++) { if (checkedOut[i] == "On the shelf") { statuses[i] = false; } else { statuses[i] = true; } } #endregion for (int i = 0; i < Titles.Length; i++) { Book book = new Book(Titles[i], Authors[i], dueDates[i], Types[i], statuses[i]); bookDb.Add(book); } BookListView listView = new BookListView(bookDb); Console.WriteLine("\n\n\n"); Console.WriteLine("{0," + (Console.WindowWidth / 2) + "}", "Hello, welcome to the Grand Circus Library!"); Console.WriteLine("{0," + (Console.WindowWidth / 2) + "}", "***[PLEASE MAKE FULLSCREEN]***\n\n"); while (response == "yes") { //Maybe prompt a rotating selection of 'popular' books as a 'book of the day or hotest author'. DisplayBorder(); DisplayMenuWithBorder("\tHere are some browsing/search options:"); DisplayMenuWithBorder("\t "); DisplayMenuWithBorder("\t1. By Genre"); DisplayMenuWithBorder("\t2. By Author"); DisplayMenuWithBorder("\t3. By Specific Title"); DisplayMenuWithBorder("\t4. By Checkout Status"); DisplayMenuWithBorder("\t5. Expected Returns"); DisplayMenuWithBorder("\t6. All Books"); DisplayMenuWithBorder("\t7. Quit"); DisplayBorder(); Console.Write("\nMENU OPTION: "); string choice = Console.ReadLine(); Console.Clear(); if (int.TryParse(choice, out int num)) { switch (num) { case 1: //Genre { DisplayBorder(); DisplayMenuWithBorder("Here are our available types of books:"); DisplayMenuWithBorder(" "); DisplayBorder(); DisplayGenre(); break; } case 2: //Author { DisplayBorder(); DisplayMenuWithBorder("Here are our list of available Authors:"); DisplayMenuWithBorder(" "); DisplayBorder(); DisplayAuthor(); break; } case 3: //Title { DisplayBorder(); DisplayMenuWithBorder("What is the specific Title for a book you are looking for?"); DisplayMenuWithBorder(" "); DisplayBorder(); DisplayTitle(); break; } case 4: //Status { DisplayBorder(); DisplayMenuWithBorder("What kind of books would you like to see:"); DisplayMenuWithBorder(" "); DisplayBorder(); DisplayStatus(); break; } case 5: //Upcoming returns { DisplayBorder(); DisplayMenuWithBorder("Here are books who are 'checked out',"); DisplayMenuWithBorder("but estimated to be returned within the next two weeks: "); DisplayMenuWithBorder(" "); DisplayBorder(); DisplayDate(); break; } case 6: // All books { DisplayBorder(); DisplayMenuWithBorder("Here is our selection of ALL books: "); DisplayMenuWithBorder(" "); DisplayBorder(); DisplayAllTitle(); CheckOut(); break; } case 7: // Quit { Console.WriteLine(String.Format("{0," + ((Console.WindowWidth / 2) + ("Thank you for stopping by!".Length / 2)) + (Console.WindowHeight / 2) + "}", "Thank you for stopping by!")); response = "no"; break; } default: { Console.WriteLine("invalid input! Please enter a valid number between 1-7 \n\t(Please try again)"); break; } } } else { Console.WriteLine("invalid input! Please enter a valid number between 1-7 \n\t(Please try again)"); } Console.ReadLine(); Console.Clear(); } SaveToTxtFile(); Console.WriteLine("\nThank you!"); }
public void DisplayGenre() { BookListView listView = new BookListView(bookDb); DisplayMenuWithBorder("Young Adult"); DisplayMenuWithBorder("Thriller"); DisplayMenuWithBorder("Satire"); DisplayMenuWithBorder("Romantic"); DisplayMenuWithBorder("Fantasy"); DisplayMenuWithBorder("Children's Literature"); DisplayMenuWithBorder("Science Fiction"); DisplayMenuWithBorder("Historical Fiction"); DisplayMenuWithBorder("Gothic Fiction"); DisplayBorder(); Console.WriteLine("\nWhich type would like to see a list of?"); string choice = Console.ReadLine().ToLower(); switch (choice) { case "young adult": { Console.Clear(); DisplayCenterBorder(); listView.DisplayType("Young Adult"); DisplayCenterBorder(); CheckOut(); break; } case "thriller": { Console.Clear(); DisplayCenterBorder(); listView.DisplayType("Thriller"); DisplayCenterBorder(); CheckOut(); break; } case "satire": { Console.Clear(); DisplayCenterBorder(); listView.DisplayType("Satire"); DisplayCenterBorder(); CheckOut(); break; } case "romantic": { Console.Clear(); DisplayCenterBorder(); listView.DisplayType("Romantic"); DisplayCenterBorder(); CheckOut(); break; } case "fantasy": { Console.Clear(); DisplayCenterBorder(); listView.DisplayType("Fantasy"); DisplayCenterBorder(); CheckOut(); break; } case "children's literature": { Console.Clear(); DisplayCenterBorder(); listView.DisplayType("Children's Literature"); DisplayCenterBorder(); CheckOut(); break; } case "science fiction": { Console.Clear(); DisplayCenterBorder(); listView.DisplayType("Science Fiction"); DisplayCenterBorder(); CheckOut(); break; } case "historical fiction": { Console.Clear(); DisplayCenterBorder(); listView.DisplayType("Historical Fiction"); DisplayCenterBorder(); CheckOut(); break; } case "gotchic fiction": { Console.Clear(); DisplayCenterBorder(); listView.DisplayType("Gotchic Fiction"); DisplayCenterBorder(); CheckOut(); break; } default: { Console.Clear(); Console.WriteLine("Invalid choice! Choice must be from provided selection."); break; } } }