static void Main(string[] args) { Garage garage = new Garage(); garage.TitleScreen(); bool flag = true; while (flag) { Console.Clear(); garage.GarageScreen(); Console.WriteLine("1.Choose a car to drive\n2.Refuel all cars\n3.Add a car\n4.Remove a car\n5.List all cars\n0.Exit"); string input = Console.ReadLine(); switch (input) { case "1": garage.ListAllCars(); Console.WriteLine("Type ID to select car"); int id = Convert.ToInt32(Console.ReadLine()); SubMenu(garage.Select_Car(id)); break; case "2": garage.FuelAllCars(); Console.WriteLine("All cars are fueled up and ready to go!"); Console.ReadKey(); break; case "3": garage.AddNewCar("{0}", "{1}", 0, 100); break; case "4": garage.RemoveCar(); break; case "5": garage.ListAllCars(); Console.ReadKey(); break; case "0": flag = false; break; default: Console.WriteLine("Something went wrong."); break; } } }
static void MainMenu() { Garage myParkingGarage = new Garage(); bool run = true; do { Console.Clear(); Console.WriteLine("Main Menu:"); Console.WriteLine("Press 1 to add a car"); if (myParkingGarage.ListOfCars.Count > 0) { Console.WriteLine("Press 2 to display cars' information"); Console.WriteLine("Press 3 to display cars' stats"); Console.WriteLine("Press 4 to do something with a vehicle"); Console.WriteLine("Press 5 to remove a car"); } Console.WriteLine("Press 0 to Quit"); ConsoleKeyInfo keyPressed = Console.ReadKey(); string menuChoice; if (char.IsDigit(keyPressed.KeyChar)) { menuChoice = keyPressed.KeyChar.ToString(); } else { menuChoice = "default"; } if (!menuChoice.Equals("1") && !menuChoice.Equals("0") && myParkingGarage.ListOfCars.Count == 0) { menuChoice = "-1"; } switch (menuChoice) { case "0": Console.WriteLine("\nSee you later alligator"); run = false; break; case "1": Console.WriteLine("\nAdd Car: "); myParkingGarage.AddNewCar(); break; case "2": myParkingGarage.DisplayCarInfo(); break; case "3": myParkingGarage.DisplayCarStats(); break; case "4": myParkingGarage.InteractionMenu(); break; case "5": myParkingGarage.RemoveCar(myParkingGarage.CarSelectionMenu()); break; default: Console.WriteLine("Please follow the instructions"); Console.WriteLine("Press any key to continue"); Console.ReadKey(); break; } } while (run); }