public static Vehicle CreateVehicle(string i_ModelName, string i_LicenceNumber, List <string> i_WheelsInfo, float i_EnergyLeftPercent, eVehicleType i_VehicleType, object i_InnerVehicleInfo) { Vehicle newVehicle = null; if (i_VehicleType == eVehicleType.ElectricCar) { newVehicle = new ElectricCar(i_ModelName, i_LicenceNumber, i_WheelsInfo, i_EnergyLeftPercent, (Car)i_InnerVehicleInfo); } else if (i_VehicleType == eVehicleType.GasCar) { newVehicle = new GasCar(i_ModelName, i_LicenceNumber, i_WheelsInfo, i_EnergyLeftPercent, (Car)i_InnerVehicleInfo); } else if (i_VehicleType == eVehicleType.ElectricMotorcycle) { newVehicle = new ElectricMotorcycle(i_ModelName, i_LicenceNumber, i_WheelsInfo, i_EnergyLeftPercent, (Motorcycle)i_InnerVehicleInfo); } else if (i_VehicleType == eVehicleType.GasMotorcycle) { newVehicle = new GasMotorcycle(i_ModelName, i_LicenceNumber, i_WheelsInfo, i_EnergyLeftPercent, (Motorcycle)i_InnerVehicleInfo); } else if (i_VehicleType == eVehicleType.GasTruck) { newVehicle = new GasTruck(i_ModelName, i_LicenceNumber, i_WheelsInfo, i_EnergyLeftPercent, (Truck)i_InnerVehicleInfo); } return(newVehicle); }
public static Vehicle CreateVehicle(Vehicle.eVehicleTypes i_VehicleType, string i_Model, string i_LicenseNumber, float i_EnergyLeft, List <Wheel> i_Wheels, Engine i_engine, Dictionary <string, object> features) { Vehicle vehicle = null; switch (i_VehicleType) { case Vehicle.eVehicleTypes.ElectricCar: vehicle = new ElectricCar((Vehicle.eCarColors)features["i_CarColor"], (Vehicle.eCarDoorsAmount)features["i_CarDoors"]); break; case Vehicle.eVehicleTypes.GasCar: vehicle = new GasCar((Vehicle.eCarColors)features["i_CarColor"], (Vehicle.eCarDoorsAmount)features["i_CarDoors"]); break; case Vehicle.eVehicleTypes.ElectricMotorcycle: vehicle = new ElectricMotorcycle((Vehicle.eLicenseTypes)features["i_MotorcycleLicenseType"], (int)features["i_EngineCapacity"]); break; case Vehicle.eVehicleTypes.GasMotorcycle: vehicle = new GasMotorcycle((Vehicle.eLicenseTypes)features["i_MotorcycleLicenseType"], (int)features["i_EngineCapacity"]); break; case Vehicle.eVehicleTypes.Truck: vehicle = new Truck((bool)features["i_IsCarryingDangerousMaterials"], (float)features["i_MaximumCarryingWeight"]); break; } vehicle.m_EnergyLeft = i_EnergyLeft; vehicle.Engine = i_engine; vehicle.Wheels = i_Wheels; vehicle.LicenseNumber = i_LicenseNumber; vehicle.m_Model = i_Model; return(vehicle); }
public static Vehicle Create(eVehicleType i_VehicleType) { Vehicle newVehicle = null; switch (i_VehicleType) { case eVehicleType.GasCar: newVehicle = new GasCar(); break; case eVehicleType.ElectricCar: newVehicle = new ElectricCar(); break; case eVehicleType.GasMotor: newVehicle = new GasMotor(); break; case eVehicleType.ElectricMotor: newVehicle = new ElectricMotor(); break; case eVehicleType.Truck: newVehicle = new Truck(); break; } return(newVehicle); }
public static Vehicle GenerateNewVehicle(eVehicleToGenerate i_VehicleToGenerate, List <string> i_NewVehicleData) { Vehicle newVehicle = null; Motorcycle.eMotorcycleLicenseType motorcycleLicenseType = 0; Car.eCarColorOptions carColor = 0; Car.eNumberOfDoors carNumberOfDoors = 0; if (i_VehicleToGenerate == eVehicleToGenerate.ElectricCar || i_VehicleToGenerate == eVehicleToGenerate.GasCar) { carColor = (Car.eCarColorOptions)System.Enum.Parse(typeof(GasCar.eCarColorOptions), i_NewVehicleData[k_PlaceHolderForCarColor]); carNumberOfDoors = (Car.eNumberOfDoors)System.Enum.Parse(typeof(Car.eNumberOfDoors), i_NewVehicleData[k_PlaceHolderForCarDoorsNumber]); } if (i_VehicleToGenerate == eVehicleToGenerate.ElectricMotorcycle || i_VehicleToGenerate == eVehicleToGenerate.GasMotorcycle) { motorcycleLicenseType = (Motorcycle.eMotorcycleLicenseType)System.Enum.Parse(typeof(Motorcycle.eMotorcycleLicenseType), i_NewVehicleData[k_PlaceHolderForMotorcycleLicenseType]); } switch (i_VehicleToGenerate) { case eVehicleToGenerate.GasTruck: Truck.eTruckCargo containsDangerousCargo = (Truck.eTruckCargo)System.Enum.Parse(typeof(Truck.eTruckCargo), i_NewVehicleData[k_PlaceHolderForTruckContainsDangerousCargo]); newVehicle = new GasTruck(k_GasTruckMaxFuelTankCapacity, containsDangerousCargo, k_GasTruckFuelType, float.Parse(i_NewVehicleData[k_PlaceHolderForTruckVolumeCapacity]), float.Parse(i_NewVehicleData[k_PlaceHolderForTruckMaxAllowedCargoWeight]), i_NewVehicleData[k_PlaceHolderForVehicleNumber], i_NewVehicleData[k_PlaceHolderForVehicleModel], k_TruckNumberOfWheels, i_NewVehicleData[k_PlaceHolderForWheelManufacturer], k_TruckMaxAirPressure); break; case eVehicleToGenerate.GasMotorcycle: newVehicle = new GasMotorcycle(k_GasMotorcycleMaxFuelTankCapacity, k_GasMotorcycleFuelType, motorcycleLicenseType, int.Parse(i_NewVehicleData[k_PlaceHolderForMotorcycleEngineCapacity]), i_NewVehicleData[k_PlaceHolderForVehicleNumber], i_NewVehicleData[k_PlaceHolderForVehicleModel], k_MotorcycleNumberOfWheels, i_NewVehicleData[k_PlaceHolderForWheelManufacturer], k_MotorcycleMaxAirPressure); break; case eVehicleToGenerate.ElectricMotorcycle: newVehicle = new ElectricMotorcycle(k_ElectricMotorcycleMaxBatteryTimeInHours, motorcycleLicenseType, int.Parse(i_NewVehicleData[k_PlaceHolderForMotorcycleEngineCapacity]), i_NewVehicleData[k_PlaceHolderForVehicleNumber], i_NewVehicleData[k_PlaceHolderForVehicleModel], k_MotorcycleNumberOfWheels, i_NewVehicleData[k_PlaceHolderForWheelManufacturer], k_MotorcycleMaxAirPressure); break; case eVehicleToGenerate.GasCar: newVehicle = new GasCar(k_GasCarMaxFuelTankCapacity, k_GasCarFuelType, carColor, carNumberOfDoors, i_NewVehicleData[k_PlaceHolderForVehicleNumber], i_NewVehicleData[k_PlaceHolderForVehicleModel], k_CarNumberOfWheels, i_NewVehicleData[k_PlaceHolderForWheelManufacturer], k_CarMaxAirPressure); break; case eVehicleToGenerate.ElectricCar: newVehicle = new ElectricCar(k_ElectricCarMaxBatteryTimeInHours, carColor, carNumberOfDoors, i_NewVehicleData[k_PlaceHolderForVehicleNumber], i_NewVehicleData[k_PlaceHolderForVehicleModel], k_CarNumberOfWheels, i_NewVehicleData[k_PlaceHolderForWheelManufacturer], k_CarMaxAirPressure); break; default: break; } return(newVehicle); }
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); }