public static bool MainMenu(CardCatalog cc) { Console.WriteLine("1) List all books."); Console.WriteLine("2) Add a book."); Console.WriteLine("3) Save and Exit."); string result = Console.ReadLine(); if (result == "1") { cc.ListAllBooks(); return(true); } else if (result == "2") { cc.AddABook(); return(true); } else if (result == "3") { cc.Save(); return(false); } else { return(true); } }
private static bool DisplayMenu(bool status) { Console.WriteLine(); Console.WriteLine("Menu"); Console.WriteLine("1) List all books"); Console.WriteLine("2) Add a book"); Console.WriteLine("3) Save and Exit"); string Input = Console.ReadLine(); switch (Input) { case "1": CardCatalog.ListBooks(); break; case "2": CardCatalog.AddBook(); break; case "3": CardCatalog.SaveXML(); status = true; break; default: break; } return(status); }
private static bool MainMenu(CardCatalog cc) { Console.WriteLine("Select a number"); Console.WriteLine("1. List All Books"); Console.WriteLine("2. Add a Book"); Console.WriteLine("3. Save and Exit"); string option = Console.ReadLine(); int num = int.Parse(option); if (num == 1) { cc.ListAllBooks(); } else if (num == 2) { Console.WriteLine("1.Enter Title: "); string title = Console.ReadLine(); Console.WriteLine("2.Enter Author: "); string author = Console.ReadLine(); Console.WriteLine("3.Enter ISBN: "); string ISBN = Console.ReadLine(); cc.AddBook(new Book(author, title, ISBN)); } else if (num == 3) { cc.savememorytofile(); return(false); } return(true); }
static void Main(string[] args) { Console.WriteLine("Enter a file: "); string filename = Console.ReadLine(); CardCatalog cc = new CardCatalog(filename); DisplayMenu(cc); }
public static void DisplayMenu(CardCatalog cc) { bool displayMenu = true; while (displayMenu) { displayMenu = MainMenu(cc); Console.WriteLine(); } }
static void Main(string[] args) { CardCatalog.Initialize(); bool Status = false; do { Status = DisplayMenu(Status); }while (Status == false); }
static void Main(string[] args) { //I'm so lost man, how does Git work? //I know Console.WriteLine("Enter the name of a file: "); string inputfilename = Console.ReadLine(); CardCatalog cc = new CardCatalog(inputfilename); bool displaymenu = true; while (displaymenu) { displaymenu = MainMenu(cc); } }
static void Main(string[] args) { //Prompt List Code Console.WriteLine("Please enter a file name: "); string file = Console.ReadLine(); CardCatalog cardCat = new CardCatalog(file); string promptAnswer = ""; do { string[] lines = { "Please hit 1, 2, or 3 then enter: ", "1. List All books", "2. Add A Book", "3. Save and Exit" }; foreach (string line in lines) { Console.WriteLine(line); } try { promptAnswer = Console.ReadLine(); switch (promptAnswer) { case "1": cardCat.ListBooks(); break; case "2": cardCat.AddBook(); break; case "3": cardCat.Save(); break; } } catch (Exception ex) { Console.WriteLine(ex); } } while (promptAnswer != "3"); }
static void Main(string[] args) { bool hasSpace = true; while (hasSpace) { Console.WriteLine("What one-word name would you like to call your card catalog?"); string fileName = Console.ReadLine(); hasSpace = fileName.Contains(" "); if (hasSpace) { Console.WriteLine("I'm sorry, your name fails to meet the one-word requirement, please try again..."); } else { Console.WriteLine("Thank you! Please choose an option from the menu below:"); new CardCatalog(fileName); } } string userChoice = MainMenu(); while (userChoice != "3") { if (userChoice == "1") { CardCatalog.ListBooks(); userChoice = MainMenu(); } else if (userChoice == "2") { CardCatalog.AddBook(); userChoice = MainMenu(); } } CardCatalog.Save(); }