Exemplo n.º 1
0
        private void printSupportedTypes()
        {
            StringBuilder outputMess = new StringBuilder();

            CreateNewObjForGarage.eVehicle[] vehicleTypes = CreateNewObjForGarage.GetSupportedTypes();
            for (int i = 0; i < vehicleTypes.Length; i++)
            {
                outputMess.Append("for " + vehicleTypes[i]);
                outputMess.AppendLine(" press " + (int)vehicleTypes[i] + " ");
            }

            Console.WriteLine(outputMess);
        }
Exemplo n.º 2
0
        private CreateNewObjForGarage.eVehicle getValidVehicleType()
        {
            CreateNewObjForGarage.eVehicle[] vehicleTypes = CreateNewObjForGarage.GetSupportedTypes();
            string vehicleTypeStr = Console.ReadLine();
            int    vehicleType;

            while (!int.TryParse(vehicleTypeStr, out vehicleType) || !isCorrectTypeOfVehicle(vehicleType))
            {
                Console.WriteLine("Please enter a digit from the options");
                vehicleTypeStr = Console.ReadLine();
            }

            return((CreateNewObjForGarage.eVehicle)vehicleType);
        }
Exemplo n.º 3
0
        private bool isCorrectTypeOfVehicle(int i_VehicleType)
        {
            CreateNewObjForGarage.eVehicle[] vehicleTypes = CreateNewObjForGarage.GetSupportedTypes();
            bool isCorrect = false;

            for (int i = 0; i < vehicleTypes.Length; i++)
            {
                if ((int)vehicleTypes[i] == i_VehicleType)
                {
                    isCorrect = true;
                }
            }

            return(isCorrect);
        }
Exemplo n.º 4
0
        private Vehicle getVehicle(string i_LicensePlateNumber)
        {
            Vehicle vehicleToAddToGarage;

            CreateNewObjForGarage.eVehicle vehicleType;
            List <string> listOfQuestions, listOfAttributesToGet;
            string        model;

            Console.WriteLine("Please enter the vehicle you want to add:");
            printSupportedTypes();
            vehicleType = getValidVehicleType();
            Console.WriteLine("Please enter the model of the vehicle");
            model = returnStringIfNotEmpty();
            vehicleToAddToGarage = CreateNewObjForGarage.MakeNewVehicle(vehicleType, model, i_LicensePlateNumber, out listOfQuestions, out listOfAttributesToGet);
            getAndSetInputAccordingToQuestions(vehicleToAddToGarage, listOfQuestions, listOfAttributesToGet);
            return(vehicleToAddToGarage);
        }