static void Main(string[] args) { Garage my = new Garage(); my.AddCar("Ford", "Focus"); my.AddCar("Chevy", "Silverado"); my.AddCar("Audi", "R8"); bool flag = true; Console.WriteLine("\t\t\t3 To create a car"); Console.WriteLine("\t\t\t2 To print list of cars"); Console.WriteLine("\t\t\t1 To select a car with ID"); while (flag) { String input = Console.ReadLine(); switch (input) { case "1": Console.WriteLine("Type ID to select a car, press 2 to print all cars"); int index = Convert.ToInt32(Console.ReadLine()); Submenu(my.Select_Car(index)); break; case "2": my.ListAllCars(); Console.WriteLine("\t\t\t1 To select a car with ID"); break; case "3": Console.WriteLine("Please type Make and Model of your car"); string make = Console.ReadLine(); string model = Console.ReadLine(); my.AddCar(make, model); break; case "0": flag = false; break; default: Console.WriteLine("Something went wrong"); break; } } }
static void Main(string[] args) { Garage BriansGarage = new Garage(); string userInput; Console.WriteLine("Select 1 to add a new car to your garage"); Console.WriteLine("Select 2 to remove a car from your garage"); Console.WriteLine("Select 3 to view all cars in your garage"); Console.WriteLine("Select 4 to test drive a car"); Console.WriteLine("Select 5 to refuel all the cars in your garage"); userInput = Console.ReadLine(); switch (userInput) { case "1": BriansGarage.AddCar(); break; case "2": BriansGarage.RemoveCar(); break; //case "3": // BriansGarage.RemoveCar. // break; //case "4": // BriansGarage.myGarage. case "5": BriansGarage.FuelAllCars(); break; } }
static void Main(string[] args) { var garage = new Garage(); Console.WriteLine("1. Add a car to the garage."); Console.WriteLine("2. Remove a car from the garage."); Console.WriteLine("3. List all cars."); Console.WriteLine("4. Test drive a car."); Console.WriteLine("5. Refuel all cars."); string menuChoice = Console.ReadLine(); switch (menuChoice) { case "1": Console.WriteLine("What is the Make of your car?"); var make = Console.ReadLine(); Console.WriteLine("What is the Model of your car?"); var model = Console.ReadLine(); garage.AddCar(make, model); break; case "2": int carNum = Convert.ToInt32(Console.ReadLine()); garage.RemoveCar(carNum); //make this in garage as new method break; case "3": garage.ListAllCars(); break; case "4": //garage.TestDriveCar(); //make this in garage as new method Console.WriteLine("1. Turn on car"); Console.WriteLine("2. Accelerate"); Console.WriteLine("3. Brake"); Console.WriteLine("4. Turn off car"); Console.WriteLine("5. Return car"); break; case "5": garage.FuelAllCars(); break; default: Console.WriteLine("That wasn't an option! Try again."); break; } }
static Garage UserAddsCar(Garage myGarage) { Console.WriteLine("What is the car's make?"); string make = Console.ReadLine(); Console.WriteLine("What is the car's model"); string model = Console.ReadLine(); Console.WriteLine("What is the car's year?"); string year = Console.ReadLine(); myGarage.AddCar(make, model, year); Console.WriteLine("A " + year + " " + make + " " + model + " has been added to your garage!"); return(myGarage); }
static void Main(string[] args) { Console.WriteLine("\t\t\t==== Wellcome ===="); Garage mycars = new Garage(); mycars.AddCar("Chevrolet", "Silverado"); mycars.AddCar("Audi", "Q7"); mycars.AddCar("Ford", "Fusion"); Console.WriteLine(mycars.MyCars.Count.ToString()); bool run = true; Header(); do { var key = Console.ReadKey(); switch (key.KeyChar) { case (char)ConsoleKey.D1: //Print Cars Console.WriteLine("press 0 to quit"); mycars.PrintCars(); break; case (char)ConsoleKey.D2: //Select car Console.WriteLine("Please Type ID (NUMBERS) only and Press Enter : "); int selector = Convert.ToInt32(Console.ReadLine()); if (selector > mycars.MyCars.Count) { Console.WriteLine("We don't have a car with this ID number"); } else { Test_Drive(mycars.SelectCar(selector)); } break; case (char)ConsoleKey.D3: //Add car Console.Write(" Make : "); string make = Console.ReadLine(); Console.Write(" Model : "); string model = Console.ReadLine(); mycars.AddCar(make, model); Console.WriteLine("Car {0} {1} is parked in garage", make, model); break; case (char)ConsoleKey.D4: //Remove Car Console.WriteLine("Please Type ID and Press Enter to remove car from list "); int index = Convert.ToInt32(Console.ReadLine()); mycars.RemoveCar(index); Console.WriteLine("Press 1 to Print list"); break; case (char)ConsoleKey.D5: //Fuell All Cars Console.WriteLine("You fueled all cars!"); mycars.FuelAllCars(); Console.WriteLine("press 0 to quit"); break; case (char)ConsoleKey.D0: //Select car run = false; break; default: Console.WriteLine("\n\npress 0 to quit"); break; } }while (run); }
static void Main(string[] args) { MainMenu(); void MainMenu() { Console.Clear(); Console.WriteLine("=====Main Menu====="); Console.WriteLine("1. Add a car to the garage"); Console.WriteLine("2. Remove a car from the garage"); Console.WriteLine("3. List all cars."); Console.WriteLine("4. Interact with the car."); string input = Console.ReadLine(); switch (input) { case "1": myGarage.AddCar(); MainMenu(); break; case "2": myGarage.RemoveCar(); MainMenu(); break; case "3": myGarage.AllStatus(); Console.WriteLine("Press Enter to continue"); Console.ReadKey(); MainMenu(); break; case "4": CarActions(); break; default: Console.WriteLine("Please choose an appropriate number."); MainMenu(); break; } } void CarActions() { Console.Clear(); Console.WriteLine("What should we do with the " + myGarage.cars[currentCarPosition].Make + " " + myGarage.cars[currentCarPosition].Model); Console.WriteLine("1. Turn on/off engine"); Console.WriteLine("2. Accelerate"); Console.WriteLine("3. Brake"); Console.WriteLine("4. Get gas)"); Console.WriteLine("5. Return to Main Menu"); string input = Console.ReadLine(); Car myCurrentCar = myGarage.cars[currentCarPosition]; switch (input) { case "1": myCurrentCar.ToggleEngine(); if (myCurrentCar.Started == true) { Console.WriteLine("You turned on the car!"); } else { Console.WriteLine("You turned off the car!"); } Console.ReadKey(); MainMenu(); break; case "2": myCurrentCar.Accelerate(); Console.WriteLine("You stepped on the gas! Speed is went up!"); Console.ReadKey(); MainMenu(); break; case "3": myCurrentCar.Brake(); Console.WriteLine("BREAK CHECK!!!! Your speed went down!"); Console.ReadKey(); MainMenu(); break; case "4": myCurrentCar.AddFuel(); Console.WriteLine("You filled up the tank. Wow! Someone's rich!"); Console.ReadKey(); MainMenu(); break; case "5": MainMenu(); break; default: Console.WriteLine("Please choose the number for the action."); CarActions(); break; } } void ListAllCars() { int currentCarPosition = 0; foreach (Car car in myGarage.cars) { Console.WriteLine((currentCarPosition += 1) + ". Make: " + car.Make + " Model: " + car.Model); } } void SwitchCurrent() { Console.Clear(); Console.WriteLine("Please Choose Car!"); Console.WriteLine(); currentCarPosition = 0; foreach (Car current in myGarage.cars) { Console.WriteLine((currentCarPosition += 1) + ". " + current.Make + " " + current.Model); } Console.WriteLine(); Console.WriteLine("Choose the number of the car you want to choose!"); string carPosition = Console.ReadLine(); currentCarPosition = Int32.Parse(carPosition); currentCarPosition--; Console.Clear(); Console.WriteLine("You are now using " + myGarage.cars[currentCarPosition].Make + " " + myGarage.cars[currentCarPosition].Model); Console.ReadKey(); MainMenu(); } }
//It is very open to your interpretation, but it could look something like below, which basically gives the user the ability to interact with all the methods you created-> //A example Main menu to interact with the garage: //1. Add a Car to the Garage //2. Remove a Car from the Garage //3. List all Cars //4. Test drive a car //5. Refuel all cars //And then a sub menu to interact with the car that was selected(under 4. Test drive a car): //1. Turn on car //2. Accelerate //3. Brake //4. Turn off car //5. Return car static void Main(string[] args) { Garage joeGarage = new Garage(); int selection = 0; restartMainMenu(); do { var input = Console.ReadKey(false).Key; switch (input) { case ConsoleKey.D1: //the D1 means "1" above the q key and Numpad1 means "1" on num pad! case ConsoleKey.NumPad1: //once you're in the switch, it continues until a break, so D1 or NumPad1 //Console.WriteLine("Decision Has Been Made!!! - 1\n"); selection = 1; Console.WriteLine("Add a Car to the Garage!\n"); Console.Write("\tEnter Make: "); string theMake = Console.ReadLine(); Console.Write("\n\tEnter Model: "); string theModel = Console.ReadLine(); joeGarage.AddCar(theMake, theModel); restartMainMenu(); break; case ConsoleKey.D2: case ConsoleKey.NumPad2: //Console.WriteLine("Decision Has Been Made!!! - 2\n"); selection = 2; Console.WriteLine("Remove a Car from the Garage!\n"); Console.Write("\tEnter Make: "); string theRemovedMake = Console.ReadLine(); Console.Write("\n\tEnter Model: "); string theRemovedModel = Console.ReadLine(); joeGarage.RemoveCarByMakeAndModel(theRemovedMake, theRemovedModel); Console.WriteLine("\n...Press Enter to Continue"); Console.ReadLine(); restartMainMenu(); break; case ConsoleKey.D3: case ConsoleKey.NumPad3: //Console.WriteLine("Decision Has Been Made!!! - 3\n"); selection = 3; Console.WriteLine(" MAKE MODEL RUNNING? FUEL SPEED"); for (int car = 0; car < joeGarage.TheGarage.Count; car++) { Console.WriteLine(car + " " + joeGarage.AllStatsofCarToString(car)); } Console.WriteLine("\n...Press Enter to Continue"); Console.ReadLine(); restartMainMenu(); break; case ConsoleKey.D4: case ConsoleKey.NumPad4: //Console.WriteLine("Decision Has Been Made!!! - 4\n"); selection = 4; carOpsMenu(ref joeGarage); selection = 0; restartMainMenu(); break; case ConsoleKey.D5: case ConsoleKey.NumPad5: Console.WriteLine("Decision Has Been Made!!! - 5\n"); selection = 5; joeGarage.FuelAllCars(); Console.WriteLine("\n...Press Enter to Continue"); Console.ReadLine(); restartMainMenu(); break; case ConsoleKey.Escape: selection = 6; break; case ConsoleKey.Enter: break; default: break; } } while (selection != 6); }