static void Main(string[] args) { // Call UserInterface class to build menu and recieve user input. UserInterface newUser = new UserInterface(); String input = Console.ReadLine(); int choice = newUser.RecieveInput(); // Call WineItemCollection class to create array. WineItemCollection wineItemCollection = new WineItemCollection(); // While loop build to process user input. while (choice != 5) { if (choice == 1) // Option 1 loads the array. { wineItemCollection.Collection(); Console.WriteLine(); Console.WriteLine("Done."); } else if (choice == 2) // Option 2 prints the array. { wineItemCollection.Print(); } else if (choice == 3) // Option 3 allows user to search for a specific { // Item in the array. Console.WriteLine("Enter the item you wish to search for:"); wineItemCollection.SearchList(); } else if (choice == 4) // Option 4 allows the user to add an item to the { // the array. Console.WriteLine("Enter the item you wish to add:"); wineItemCollection.AddItem(); } else if (choice == 5) // Option 5 stops the array, and allows the { // program to close. Console.WriteLine("Have a nice day."); } input = Console.ReadLine(); choice = newUser.RecieveInput(); } }
static void Main(string[] args) { // Call UserInterface class to build menu and recieve user input. UserInterface newUser = new UserInterface(); String input = Console.ReadLine(); int choice = newUser.RecieveInput(); // Call WineItemCollection class to create array. WineItemCollection wineItemCollection = new WineItemCollection(); // While loop build to process user input. while (choice != 5) { if (choice == 1) // Option 1 loads the array. { wineItemCollection.Collection(); Console.WriteLine(); Console.WriteLine("Done."); } else if (choice == 2) // Option 2 prints the array. { wineItemCollection.Print(); } else if (choice == 3) // Option 3 allows user to search for a specific { // Item in the array. Console.WriteLine("Enter the item you wish to search for:"); wineItemCollection.SearchList(); } else if (choice == 4) // Option 4 allows the user to add an item to the { // the array. Console.WriteLine("Enter the item you wish to add:"); wineItemCollection.AddItem(); } else if (choice == 5) // Option 5 stops the array, and allows the { // program to close. Console.WriteLine("Have a nice day."); } input = Console.ReadLine(); choice = newUser.RecieveInput(); } }
static void Main(string[] args) { int choiceInt = 1; string idString; UserInterface ui = new UserInterface(); CSVProcessor csvp = new CSVProcessor(); WineItemCollection WIC = new WineItemCollection(); while (choiceInt != 0) { bool error = false; ui.DisplayMenu(); try { choiceInt = Convert.ToInt32(ui.ReadLine()); } catch { ui.InvalidEntry(); error = true; } if (!error) { switch (choiceInt) { case 0: break; case 1: //Load the file if (csvp.Loaded) ui.FilesAlreadyLoaded(); else { csvp.LoadFiles(); ui.FilesLoaded(); } break; case 2: //Display all files if (csvp.Loaded) ui.DisplayFiles(); else ui.FilesNotLoaded(); break; case 3: //Find item by id if (csvp.Loaded) { ui.ItemSearchMessage(); idString = ui.ReadLine(); ui.ItemSearchResult(WIC.FindItem(idString)); } else ui.FilesNotLoaded(); break; case 4: //Add item if (csvp.Loaded) { WineItem temp = new WineItem(ui.NewItemId(), ui.NewItemDescription(), ui.NewItemPack()); ui.DisplayText(WIC.AddItem(temp)); } else ui.FilesNotLoaded(); break; default: ui.AnotherNumber(); break; } } } }