示例#1
0
 public CarInfo(string i_VehicleModelName, string i_WheelsManufacturerName, string i_LicensePlate,
                int i_NumberOfWheels, float i_WheelsMaximumAirPressure,
                Enums.eCarColor i_CarColor, Enums.eNumberOfDoors i_NumberOfDoors)
     : base(
         i_VehicleModelName, i_WheelsManufacturerName, i_LicensePlate, i_NumberOfWheels,
         i_WheelsMaximumAirPressure)
 {
     CarColor      = i_CarColor;
     NumberOfDoors = i_NumberOfDoors;
 }
示例#2
0
        private static VehicleInfo getVehicleInfo(eVehicleType i_VehicleType, string i_VehicleModelName,
                                                  string i_WheelsManufacturerName, string i_LicensePlate,
                                                  object[] i_SpecificVehicleParams)
        {
            VehicleInfo vehicleInfo;

            switch (i_VehicleType)
            {
            case eVehicleType.Car:
                Enums.eCarColor carColor =
                    Helpers.StrongArgumentNeededTypeCheckAndCast <Enums.eCarColor>(
                        i_SpecificVehicleParams[(int)eCarSpecificParams.CarColor]);
                Enums.eNumberOfDoors numberOfDoors =
                    Helpers.StrongArgumentNeededTypeCheckAndCast <Enums.eNumberOfDoors>(
                        i_SpecificVehicleParams[(int)eCarSpecificParams.NumberOfDoors]);

                vehicleInfo = new CarInfo(i_VehicleModelName, i_WheelsManufacturerName, i_LicensePlate,
                                          Constants.k_CarWheelsNumber,
                                          Constants.k_CarWheelsMaxAirPressure,
                                          carColor, numberOfDoors);

                break;

            case eVehicleType.Motorcycle:
                Enums.eLicenseType licenseType =
                    Helpers.StrongArgumentNeededTypeCheckAndCast <Enums.eLicenseType>(
                        i_SpecificVehicleParams[(int)eMotorcycelSpecificParams.LicenseType]);
                int engineVolume =
                    Helpers.StrongArgumentNeededTypeCheckAndCast <int>(
                        i_SpecificVehicleParams[(int)eMotorcycelSpecificParams.EngineVolume]);

                vehicleInfo = new MotorcycleInfo(i_VehicleModelName, i_WheelsManufacturerName, i_LicensePlate,
                                                 Constants.k_MotorcycleWheelsNumber,
                                                 Constants.k_MotorcycleWheelsMaxAirPressure, licenseType, engineVolume);

                break;

            case eVehicleType.Truck:

                vehicleInfo = new TruckInfo(i_VehicleModelName, i_WheelsManufacturerName, i_LicensePlate,
                                            Constants.k_TruckWheelsNumber,
                                            Constants.k_TruckWheelsMaxAirPressure);

                break;

            default:
                throw new ArgumentOutOfRangeException("i_VehicleType");
            }
            return(vehicleInfo);
        }
示例#3
0
文件: Car.cs 项目: eransh200/Garage
        // Sets All the car members , overriding Vehicle Set method
        public override void Set(List <string> i_DataList)
        {
            base.Set(i_DataList);
            for (int i = 0; i < k_NumberOfWheels; i++)
            {
                m_WheelCollection[i].ManufacturerName   = i_DataList[k_WheelManufacturerQLocation];
                m_WheelCollection[i].CurrentAirPressure = float.Parse(i_DataList[k_WheelAirPressureQLocation]);
            }

            m_CarColor      = (Enums.eCarColor)Enum.Parse(typeof(Enums.eCarColor), i_DataList[k_CarColorQLocation]);
            m_NumberOfDoors = (Enums.eNumberOfDoors)Enum.Parse(typeof(Enums.eNumberOfDoors), i_DataList[k_NumberOfDoorsQLocation]);
            if (m_MyEngine is FuelEngine)
            {
                (m_MyEngine as FuelEngine).GasType         = Enums.eGasType.Octan96;
                (m_MyEngine as FuelEngine).MaxCapacity     = 42;
                (m_MyEngine as FuelEngine).CurrentCapacity = m_EnergyLeft;
            }
            else
            {
                (m_MyEngine as ElectricEngine).MaxCapacity     = 2.5f;
                (m_MyEngine as ElectricEngine).CurrentCapacity = m_EnergyLeft;
            }
        }