Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
        static Garage UserRemovesCar(Garage myGarage)
        {
            Console.WriteLine("Which car would you like to select?");
            int whichCar = SelectCar(myGarage);

            Console.WriteLine("A " + myGarage.ParkingSpots[whichCar].Year + " " + myGarage.ParkingSpots[whichCar].Make + " " + myGarage.ParkingSpots[whichCar].Model + " has been removed from your garage!");

            myGarage.RemoveCar(whichCar);

            return(myGarage);
        }
Ejemplo n.º 3
0
        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;
                }
            }
        }
Ejemplo n.º 4
0
        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;
            }
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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();
            }
        }