Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace RestaurantAssignment
- {
- class Program
- {
- static void PrintHelp()
- {
- Console.WriteLine("Welcome to Steve's Fishshop please select an option: ");
- Console.WriteLine("Select option 1 to add a food item... ");
- Console.WriteLine("Select option 2 to add a drink item...");
- Console.WriteLine("Select option 3 to print a list of current items...");
- Console.WriteLine("Select option 4 to edit exsisting records...");
- Console.WriteLine("Select option 5 to output the total cost... ");
- Console.WriteLine("Select option 6 to quit selection...");
- }
- static void Main(string[] args)
- {
- Stock stockList = new Stock();
- // Adding food and drink items to start the list
- //stockList.Foods.Add(new FoodItem { Name = "Cod and chips", Description = "A large fillet of cod with our famous chunky fries!" });
- //stockList.Foods.Add(new FoodItem { Name = "Curry and chips", Description = "Spicy curry sauce finished with either our chunky or fine fries... both are great!" });
- //stockList.Foods.Add(new FoodItem { Name = "Freddie's fishcakes", Description = "Our fine blend fishcakes cooked fresh on the premises!" });
- //stockList.Drinks.Add(new DrinkItem { Name = "Lemonade", Description = "Freshly squeezed lemonade" });
- //open file
- while (true)
- {
- PrintHelp();
- Console.Write("> ");
- string input = Console.ReadLine();
- switch (input)
- {
- // to add a food item...
- case "1":
- stockList.AddFoodItem();
- break;
- // add a drink item...
- case "2":
- stockList.AddDrinkItem();
- break;
- // print a list of current items...
- case "3":
- Console.WriteLine("Foods: ");
- Console.WriteLine(String.Join(", ", stockList.GetFoodNames()));
- Console.WriteLine("");
- Console.WriteLine("Drinks: ");
- Console.WriteLine(String.Join(", ", stockList.GetDrinkNames()));
- break;
- // edit exsisting records...
- case "4":
- Console.WriteLine("Would you like to edit food or drink?");
- var choice = Console.ReadLine();
- Console.WriteLine("Please enter the ID of the item you wish to edit:");
- Console.WriteLine("");
- if (choice.ToLower() == "drink" || choice.ToLower() == "drinks")
- {
- Console.WriteLine("Drinks:");
- foreach (var drink in stockList.Drinks)
- {
- Console.WriteLine($"{stockList.Drinks.IndexOf(drink)}) {drink.Name}");
- }
- // Get the ID of the item
- Console.WriteLine("");
- Console.Write("> ");
- var id = Convert.ToInt32(Console.ReadLine());
- // Pull the item from the List
- var item = stockList.Drinks[id];
- stockList.Drinks.Remove(item); // Remove old item
- // Add the new update item
- stockList.AddDrinkItem();
- }
- else if (choice.ToLower() == "food" || choice.ToLower() == "foods")
- {
- Console.WriteLine("Foods:");
- foreach (var food in stockList.Foods)
- {
- Console.WriteLine($"{stockList.Foods.IndexOf(food)}) {food.Name}");
- }
- // Get the ID of the item
- Console.WriteLine("");
- Console.Write("> ");
- var id = Convert.ToInt32(Console.ReadLine());
- // Pull the item from the List
- var item = stockList.Foods[id];
- stockList.Foods.Remove(item); // Remove old item
- // Add the new update item
- stockList.AddFoodItem();
- }
- break;
- // output the total cost...
- case "5":
- Console.WriteLine("The total cost is: " + stockList.TotalCost());
- break;
- // to quit selection...
- case "6":
- return;
- }
- // Block so the user has time to read results
- Console.WriteLine(""); // Assign whitespace so dialogue is less cluttered
- Console.WriteLine("Press any key to continue.");
- Console.ReadKey(true);
- Console.Clear();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement