public static void Main()
        {
            // $G$ CSS-000 (-3) The variable name is not meaningful and understandable, don't use abbreviation.
            Interface             i = new Interface();
            GarageObjectGenerator g = new GarageObjectGenerator();
            Garage h = new Garage();

            i.RunSystem(h, g);
        }
Exemple #2
0
        public void RunSystem(Garage i_TheGarage, GarageObjectGenerator i_VehicleGenerator)
        {
            Console.WriteLine("Welcome To The Garage!{0}", Environment.NewLine);

            string menuOption = string.Empty;

            // $G$ CSS-018 (-3) You should have used enumerations here.

            while (true)
            {
                PrintMenu();
                menuOption = Console.ReadLine();

                if (menuOption == "1")
                {
                    AddNewVehicleToGarage(i_VehicleGenerator, i_TheGarage);
                }
                else if (menuOption == "2")
                {
                    ShowLicensePlateNumberOfVehiclesInGarage(i_TheGarage);
                }
                else if (menuOption == "3")
                {
                    ChangeVehicleStatus(i_TheGarage);
                }
                else if (menuOption == "4")
                {
                    InflateVehicleWheels(i_TheGarage);
                }
                else if (menuOption == "5")
                {
                    FuelVehicle(i_TheGarage);
                }
                else if (menuOption == "6")
                {
                    ChargeVehicle(i_TheGarage);
                }
                else if (menuOption == "7")
                {
                    ShowDetailsOfVehicle(i_TheGarage);
                }
                else if (menuOption == "8")
                {
                    break;
                }
                else
                {
                    Console.WriteLine("Option not valid!{0}", Environment.NewLine);
                }
            }
        }
Exemple #3
0
        private int getVehicleNumberToGenerate(GarageObjectGenerator i_VehicleGenerator)
        {
            const int k_DefaultIllegalValue = -1;
            int       userChosenVehicle     = k_DefaultIllegalValue;

            Console.WriteLine(@"Please Choose the vehicle you want to enter to the garage: (choose a number and press 'Enter')");

            int i = 1;

            foreach (Type type in i_VehicleGenerator.VehicleTypesMaintainedByGarage)
            {
                Console.WriteLine(string.Format("{0}) {1}", i, type.Name));
                i++;
            }

            bool validOption = false;

            while (!validOption)
            {
                validOption = int.TryParse(Console.ReadLine(), out userChosenVehicle);

                if (validOption && userChosenVehicle >= 1 && userChosenVehicle <= i_VehicleGenerator.VehicleTypesMaintainedByGarage.Count)
                {
                    validOption = true;
                }
                else
                {
                    Console.WriteLine(string.Format(
                                          "Invalid input, Please Enter a number from 1 to {0}",
                                          i_VehicleGenerator.VehicleTypesMaintainedByGarage.Count));
                    validOption = false;
                }
            }

            return(userChosenVehicle - 1);
        }
Exemple #4
0
        public void AddNewVehicleToGarage(GarageObjectGenerator i_VehicleGenerator, Garage i_TheGarage)
        {
            bool     newCustomerCreated = false;
            Customer newCustomer        = null;

            while (!newCustomerCreated)
            {
                Console.WriteLine("Hello and welcome to The Garage! {0}Please enter your name: (and press 'Enter')", Environment.NewLine);
                string name = Console.ReadLine();
                Console.WriteLine("Please enter your phone number: (10 digits and press 'Enter')");
                string phoneNumber = Console.ReadLine();

                try
                {
                    newCustomer        = new Customer(name, phoneNumber);
                    newCustomerCreated = true;
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception.Message);
                }
            }

            List <string> informationDemandsForVehicle = null;

            int chosenVehicleToAdd = getVehicleNumberToGenerate(i_VehicleGenerator);

            string licenseNumber = getLicensePlateNumber();

            Vehicle vehicleToAddToGarage =
                i_VehicleGenerator.GenerateNewVehicle(chosenVehicleToAdd, licenseNumber, out informationDemandsForVehicle);

            newCustomer.Vehicle = vehicleToAddToGarage;

            do
            {
                List <string> answersListFromUser = getDetailsFromUser(informationDemandsForVehicle);

                i_VehicleGenerator.VehiclesSetter(informationDemandsForVehicle, answersListFromUser, vehicleToAddToGarage);
            }while (informationDemandsForVehicle.Count != 0); // continue from here

            string msgForUser;

            try
            {
                i_TheGarage.EnterNewVehicle(newCustomer, out msgForUser);
                if (msgForUser == null)
                {
                    Console.WriteLine("vehicle entered succesfully to the garage!");
                }
                else
                {
                    Console.WriteLine(msgForUser);
                }
            }
            catch (Exception valueExcepion)
            {
                Console.WriteLine(valueExcepion.Message);
                Console.WriteLine("could not enter your vehicle, the garage can not handle it");
            }
        }