예제 #1
0
        public static Vehicle CreateKindOfVehicle(eKindOfVehicle i_KindOfVehicle, List <QuestionAnswer> i_InitialMessages)
        {
            const int k_UserName      = 0;
            const int k_UserPhone     = 1;
            const int k_LicenseNumber = 2;
            Vehicle   vehicle         = null;

            switch (i_KindOfVehicle)
            {
            case eKindOfVehicle.ElectricCar:
            {
                vehicle = new ElectricCar(i_InitialMessages[k_UserName].Answer, i_InitialMessages[k_UserPhone].Answer, i_InitialMessages[k_LicenseNumber].Answer);
                break;
            }

            case eKindOfVehicle.ElectricMotorcycle:
            {
                vehicle = new ElectricMotorcycle(i_InitialMessages[k_UserName].Answer, i_InitialMessages[k_UserPhone].Answer, i_InitialMessages[k_LicenseNumber].Answer);
                break;
            }

            case eKindOfVehicle.GasCar:
            {
                vehicle = new GasCar(i_InitialMessages[k_UserName].Answer, i_InitialMessages[k_UserPhone].Answer, i_InitialMessages[k_LicenseNumber].Answer);
                break;
            }

            case eKindOfVehicle.GasMotorcycle:
            {
                vehicle = new GasMotorcycle(i_InitialMessages[k_UserName].Answer, i_InitialMessages[k_UserPhone].Answer, i_InitialMessages[k_LicenseNumber].Answer);
                break;
            }

            case eKindOfVehicle.Truck:
            {
                vehicle = new Truck(i_InitialMessages[k_UserName].Answer, i_InitialMessages[k_UserPhone].Answer, i_InitialMessages[k_LicenseNumber].Answer);
                break;
            }
            }

            return(vehicle);
        }
예제 #2
0
        public List <QuestionAnswer> ParseInitialUserInput(List <QuestionAnswer> i_UserInput)
        {
            const int      k_PhoneNumberPlace   = 1;
            const int      k_LicenseNumberPlace = 2;
            const int      k_VehicleListPlace   = 3;
            const int      k_MinValue           = 1;
            int            userVehicle;
            int            k_MaxValue = Enum.GetNames(typeof(eKindOfVehicle)).Length;
            Vehicle        vehicle;
            eKindOfVehicle kindOfVehicle = eKindOfVehicle.ElectricCar;

            userVehicle = int.Parse(i_UserInput[k_VehicleListPlace].Answer);
            validatePhoneNumber(i_UserInput[k_PhoneNumberPlace].Answer);
            validateLicenseNumber(i_UserInput[k_LicenseNumberPlace].Answer);
            IsVehicleExists(i_UserInput[k_LicenseNumberPlace].Answer);
            IsNumInRange(k_MinValue, k_MaxValue, userVehicle, "The vehicle kind you gave ");
            kindOfVehicle = (eKindOfVehicle)userVehicle;
            vehicle       = VehicleCreator.CreateKindOfVehicle(kindOfVehicle, i_UserInput);
            m_DataBase.Add(vehicle);

            return(vehicle.GetQuestions());
        }