//"overloaed" constructor public Menu(int number, string name, MealDescription description, VegetableSide vegetable, SecondSide side_second, bool hasSoda, double price) { Number = number; Name = name; DescriptionOfMeal = description; SideOfVegetable = vegetable; Side_Second = side_second; HasSoda = hasSoda; Price = price; }
private void AddMeal() { Menu newMenu = new Menu(); Console.WriteLine("Enter the Meal Number:"); string numberStr = Console.ReadLine(); int number = int.Parse(numberStr); newMenu.Number = number; Console.WriteLine("Enter the Name of the Meal item:"); string name = Console.ReadLine(); newMenu.Name = name; Console.WriteLine("Enter the corresponding number for the Meal Description:\n" + "1. Sandwich\n" + "2. Salad\n" + "3. Dinner"); string DInput = Console.ReadLine(); int DescInput = int.Parse(DInput); MealDescription description = new MealDescription(); //first one is enum name switch (DescInput) { case 1: description = MealDescription.Sandwich; break; case 2: description = MealDescription.Salad; break; case 3: description = MealDescription.Dinner; break; default: Console.WriteLine("Please enter an appropriate number."); break; } newMenu.DescriptionOfMeal = description; Console.WriteLine("Enter the corresponding number for the Vegetable Side:\n" + "1. Corn\n" + "2. Beans\n" + "3. Brocooli"); string VInput = Console.ReadLine(); int VegInput = int.Parse(VInput); VegetableSide vegetable = new VegetableSide(); //first one is enum name switch (VegInput) { case 1: vegetable = VegetableSide.Corn; break; case 2: vegetable = VegetableSide.Beans; break; case 3: vegetable = VegetableSide.Broccoli; break; default: Console.WriteLine("Please enter an appropriate number."); break; } newMenu.SideOfVegetable = vegetable; Console.WriteLine("Enter the corresponding number for the Second Side:\n" + "1. Slaw\n" + "2. Bread\n" + "3. Fries"); string SInput = Console.ReadLine(); int SSInput = int.Parse(SInput); SecondSide side_second = new SecondSide(); //first one is enum name switch (SSInput) { case 1: side_second = SecondSide.Slaw; break; case 2: side_second = SecondSide.Bread; break; case 3: side_second = SecondSide.Fries; break; default: Console.WriteLine("Please enter an appropriate number."); break; } newMenu.Side_Second = side_second; Console.WriteLine("Does the meal include a Soda?Y/N:"); string hasSodaStr = Console.ReadLine().ToLower(); bool hasSoda; if (hasSodaStr.Contains("y")) { hasSoda = true; } else { hasSoda = false; } newMenu.HasSoda = hasSoda; Console.WriteLine("Enter the Price of the Meal item:"); string priceStr = Console.ReadLine(); double price = double.Parse(priceStr); newMenu.Price = price; _menuRepo.AddMealToList(newMenu); }