public static Vehicle CreateVehicle(eVehicleType i_VehicleType, string i_ModelName, string i_LicenseNumber) { Vehicle vehicleToCreate = null; switch (i_VehicleType) { case eVehicleType.FuelCar: vehicleToCreate = new FuelCar(i_ModelName, i_LicenseNumber); break; case eVehicleType.ElectricCar: vehicleToCreate = new ElectricCar(i_ModelName, i_LicenseNumber); break; case eVehicleType.FuelMotorcycle: vehicleToCreate = new FuelMotorcycle(i_ModelName, i_LicenseNumber); break; case eVehicleType.ElectricMotorcycle: vehicleToCreate = new ElectricMotorcycle(i_ModelName, i_LicenseNumber); break; case eVehicleType.FuelTruck: vehicleToCreate = new FuelTruck(i_ModelName, i_LicenseNumber); break; default: break; } return(vehicleToCreate); }
public static Vehicle Generate(string i_WheelManufacturerName, string i_ModelName, string i_LicensePlate, TypeOfVehicle type) { Vehicle vehicleToReturn = null; switch (type) { case TypeOfVehicle.CombustionCar: vehicleToReturn = new CombustionCar(i_WheelManufacturerName, i_ModelName, i_LicensePlate); break; case TypeOfVehicle.CombustionMotorcycle: vehicleToReturn = new CombustionMotorcycle(i_WheelManufacturerName, i_ModelName, i_LicensePlate); break; case TypeOfVehicle.ElectricCar: vehicleToReturn = new ElectricCar(i_WheelManufacturerName, i_ModelName, i_LicensePlate); break; case TypeOfVehicle.ElectricMotorcycle: vehicleToReturn = new ElectricMotorcycle(i_WheelManufacturerName, i_ModelName, i_LicensePlate); break; case TypeOfVehicle.Truck: vehicleToReturn = new Truck(i_WheelManufacturerName, i_ModelName, i_LicensePlate); break; } return(vehicleToReturn); }
internal static Dictionary <string, List <string> > GetVehicleProperties(eVehicleType i_VehicleType) { Vehicle vehicle = null; switch (i_VehicleType) { case eVehicleType.Car: vehicle = new FuelCar(); break; case eVehicleType.ElectricCar: vehicle = new ElectricCar(); break; case eVehicleType.Motorcycle: vehicle = new FuelMotorcycle(); break; case eVehicleType.ElectricMotorcycle: vehicle = new ElectricMotorcycle(); break; case eVehicleType.Truck: vehicle = new Truck(); break; } return(vehicle.GetVehicleProperties()); }
internal static Vehicle CreateVehicle(eVehicleType i_VehicleType, Dictionary <string, string> i_VehicleProperties) { Vehicle vehicle = null; switch (i_VehicleType) { case eVehicleType.Car: vehicle = new FuelCar(); break; case eVehicleType.ElectricCar: vehicle = new ElectricCar(); break; case eVehicleType.Motorcycle: vehicle = new FuelMotorcycle(); break; case eVehicleType.ElectricMotorcycle: vehicle = new ElectricMotorcycle(); break; case eVehicleType.Truck: vehicle = new Truck(); break; } vehicle.SetVehicleProperties(i_VehicleProperties); return(vehicle); }
public Vehicle GetVehicle(string i_VehicleType, string i_LicenseId, string i_NameOfModel, float i_EnergyPrecent) { Vehicle vehicle = null; if (i_VehicleType.Equals("Fuel Bike")) { vehicle = new FuelBike(i_LicenseId, i_NameOfModel, i_EnergyPrecent); } else if (i_VehicleType.Equals("Electric Bike")) { vehicle = new ElectricBike(i_LicenseId, i_NameOfModel, i_EnergyPrecent); } else if (i_VehicleType.Equals("Fuel Car")) { vehicle = new FuelCar(i_LicenseId, i_NameOfModel, i_EnergyPrecent); } else if (i_VehicleType.Equals("Electric Car")) { vehicle = new ElectricCar(i_LicenseId, i_NameOfModel, i_EnergyPrecent); } else if (i_VehicleType.Equals("Truck")) { vehicle = new Truck(i_LicenseId, i_NameOfModel, i_EnergyPrecent); } else { throw new FormatException("The Vheicle type doen't exist"); } return(vehicle); }
public static Vehicle Create(eVehicleTypes i_Identifier, List <object> i_ParamsArray, Wheel[] i_Wheels) { Vehicle vehicleToReturn = null; switch (i_Identifier) { case eVehicleTypes.FuelCar: vehicleToReturn = new FuelCar((string)i_ParamsArray[0], (string)i_ParamsArray[1], (float)i_ParamsArray[2], (eCarColor)i_ParamsArray[3], (eDoorsNumber)i_ParamsArray[4], i_Wheels); break; case eVehicleTypes.FuelMotorcycle: vehicleToReturn = new FuelMotorcycle((string)i_ParamsArray[0], (string)i_ParamsArray[1], (float)i_ParamsArray[2], (eLicenseTypes)i_ParamsArray[3], (int)i_ParamsArray[4], i_Wheels); break; case eVehicleTypes.ElectricMotorcycle: vehicleToReturn = new ElectricMotorcycle((string)i_ParamsArray[0], (string)i_ParamsArray[1], (float)i_ParamsArray[2], (eLicenseTypes)i_ParamsArray[3], (int)i_ParamsArray[4], i_Wheels); break; case eVehicleTypes.ElectricCar: vehicleToReturn = new ElectricCar((string)i_ParamsArray[0], (string)i_ParamsArray[1], (float)i_ParamsArray[2], (eCarColor)i_ParamsArray[3], (eDoorsNumber)i_ParamsArray[4], i_Wheels); break; case eVehicleTypes.Truck: vehicleToReturn = new Truck((string)i_ParamsArray[0], (string)i_ParamsArray[1], (float)i_ParamsArray[2], (bool)i_ParamsArray[3], (int)i_ParamsArray[4], i_Wheels); break; default: break; } return(vehicleToReturn); }
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 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 Vehicle InitVehicle(eVehicleTypes i_VehicleType) { Vehicle newVehicle = null; switch (i_VehicleType) { case eVehicleTypes.FUEL_CAR: newVehicle = new FuelCar(eFuel.OCTAN_96, r_MaxCarFuelCapability, eWheels.FOUR, r_MaxCarAirPessure); break; case eVehicleTypes.ELECTRIC_CAR: newVehicle = new ElectricCar(r_MaxCarBatteryCapabity, eWheels.FOUR, r_MaxCarAirPessure); break; case eVehicleTypes.FUEL_MOTORCYCLE: newVehicle = new FuelMotorcycle(eFuel.OCTAN_95, r_MaxMotorcycleFuelCapability, eWheels.TWO, r_MaxMotorcycleAirPessure); break; case eVehicleTypes.ELECTRIC_MOTORCYCLE: newVehicle = new ElectricMotorcycle(r_MaxMotorcycleBatteryCapabity, eWheels.TWO, r_MaxMotorcycleAirPessure); break; case eVehicleTypes.TRUCK: newVehicle = new Truck(eFuel.SOLER, r_MaxTruckFuelCapability, eWheels.SIXTEEN, r_MaxTruckAirPessure); break; default: throw new ArgumentException(string.Format("Invalid vehicle type - {0}", i_VehicleType.ToString())); } return(newVehicle); }
public static Vehicle CreateVehicle(eTypeOfVehicle i_TypeOfVehicle, string i_LicenseNumber) { Vehicle newVehicleToCreate = null; switch (i_TypeOfVehicle) { case eTypeOfVehicle.ElectricCar: newVehicleToCreate = new ElectricCar(i_LicenseNumber); break; case eTypeOfVehicle.ElectricMotorcycle: newVehicleToCreate = new ElectricMotorcycle(i_LicenseNumber); break; case eTypeOfVehicle.FuelTruck: newVehicleToCreate = new FuelTruck(i_LicenseNumber); break; case eTypeOfVehicle.FuelCar: newVehicleToCreate = new FuelCar(i_LicenseNumber); break; case eTypeOfVehicle.FuelMotorcycle: newVehicleToCreate = new FuelMotorcycle(i_LicenseNumber); break; } return(newVehicleToCreate); }
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 CreateNewVehicle(eVehicleType i_VehicleType, string i_LicenseNumber) { Vehicle newVehicle; switch (i_VehicleType) { case eVehicleType.FuelCar: newVehicle = new FuelCar(i_LicenseNumber); break; case eVehicleType.ElectricCar: newVehicle = new ElectricCar(i_LicenseNumber); break; case eVehicleType.FuelMotorbike: newVehicle = new FuelMotorbike(i_LicenseNumber); break; case eVehicleType.ElectricMotorbike: newVehicle = new ElectricMotorbike(i_LicenseNumber); break; case eVehicleType.Truck: newVehicle = new Truck(i_LicenseNumber); break; default: throw new ArgumentException("Invalid vehicle type"); } return(newVehicle); }
public Vehicle MakeNewVehicle(eVehicleTypes vehicleType) { // this method get a vehicle type and return a new vehicle according to the type recieved. Vehicle newVehicle = null; switch (vehicleType) { case eVehicleTypes.ElectricCar: newVehicle = new ElectricCar(); break; case eVehicleTypes.ElectricMotorbike: newVehicle = new ElectricMotorbike(); break; case eVehicleTypes.EnginedCar: newVehicle = new EnginedCar(); break; case eVehicleTypes.EnginedMotorbike: newVehicle = new EnginedMotorbike(); break; case eVehicleTypes.Truck: newVehicle = new Truck(); break; } return(newVehicle); }
/** * This method creates the wanted vehicle type and returns it * Throws ArgumentException if no such vehicle exists */ public static Vehicle MakeVehicle(eVehicleType i_VehicleType) { Vehicle newVehicle; switch (i_VehicleType) { case eVehicleType.ElectricMotorcycle: newVehicle = new ElectricMotorcycle(); break; case eVehicleType.FuelMotorcycle: newVehicle = new FuelMotorcycle(); break; case eVehicleType.ElectricCar: newVehicle = new ElectricCar(); break; case eVehicleType.FuelCar: newVehicle = new FuelCar(); break; case eVehicleType.FuelTruck: newVehicle = new FuelTruck(); break; default: throw new ArgumentException(string.Format("The index {0} is not supported.", i_VehicleType)); } return(newVehicle); }
public static Vehicle MakeVehicle(Vehicle.eVehicleType i_VehicleType, DetailsOfVehicle i_DetailsOfVehicle) { Vehicle newVehicle = null; switch (i_VehicleType) { case Vehicle.eVehicleType.FuelCar: newVehicle = new FuelCar(i_DetailsOfVehicle as DetailsOfFuelCar); break; case Vehicle.eVehicleType.ElectricCar: newVehicle = new ElectricCar(i_DetailsOfVehicle as DetailsOfElectricCar); break; case Vehicle.eVehicleType.ElectricMotorcycle: newVehicle = new ElectricMotorcycle(i_DetailsOfVehicle as DetailsOfElectricMotorcycle); break; case Vehicle.eVehicleType.FuelMotorcycle: newVehicle = new FuelMotorcycle(i_DetailsOfVehicle as DetailsOfFuelMotorcycle); break; case Vehicle.eVehicleType.Truck: newVehicle = new FuelTruck(i_DetailsOfVehicle as DetailsOfFuelTruck); 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 ElectricCar CreateElectricCar(string i_VehicleModel, string i_LicencePlate, float i_BatteryLeft, eCarColors i_Color, eNumOfDoors i_NumOfDoors, string i_WheelMaker, float i_WheelCurrentPressure, VehicleOwner i_Owner) { ElectricCar electricCar = new ElectricCar(i_VehicleModel, i_LicencePlate, i_BatteryLeft, k_CarMaxBattery, i_Color, k_CarNumOfWheels, i_NumOfDoors, i_Owner); GenerateWheels(electricCar, k_CarMaxWheelPressure, i_WheelMaker, i_WheelCurrentPressure); return(electricCar); }
public static Vehicle createVehicleFromType(eVehicleType i_VehicletoCreate, string i_ModelName, string i_LicenceID, object i_UniqueParameter1, object i_UniqueParameter2, string i_WheelsManfacturer, float i_AmountOfCurrentEnergyLeft) { Vehicle newVehicle = new Vehicle(i_ModelName, i_LicenceID); if ((i_VehicletoCreate == eVehicleType.FuelMotorBike) || (i_VehicletoCreate == eVehicleType.ElectricMotorBike)) { eLicenceType licenceID = (eLicenceType)i_UniqueParameter1; int engineCapacity = (int)i_UniqueParameter2; if (i_VehicletoCreate == eVehicleType.FuelMotorBike) { FuelMotorBike newFuelMotorBike = new FuelMotorBike(i_ModelName, i_LicenceID, licenceID, engineCapacity, i_WheelsManfacturer, i_AmountOfCurrentEnergyLeft); newVehicle = newFuelMotorBike; newVehicle = newVehicle as FuelMotorBike; } else { ElectricMotorBike newElectricMotorBike = new ElectricMotorBike(i_ModelName, i_LicenceID, licenceID, engineCapacity, i_WheelsManfacturer, i_AmountOfCurrentEnergyLeft); newVehicle = newElectricMotorBike; newVehicle = newVehicle as ElectricMotorBike; } } else if ((i_VehicletoCreate == eVehicleType.FuelCar) || (i_VehicletoCreate == eVehicleType.ElectricCar)) { eCarColor carColor = (eCarColor)i_UniqueParameter1; eDoorsAmount doorsAmount = (eDoorsAmount)i_UniqueParameter2; if (i_VehicletoCreate == eVehicleType.FuelCar) { FuelCar newFuelCar = new FuelCar(i_ModelName, i_LicenceID, carColor, doorsAmount, i_WheelsManfacturer, i_AmountOfCurrentEnergyLeft); newVehicle = newFuelCar; newVehicle = newVehicle as FuelCar; } else { ElectricCar newElectricCar = new ElectricCar(i_ModelName, i_LicenceID, carColor, doorsAmount, i_WheelsManfacturer, i_AmountOfCurrentEnergyLeft); newVehicle = newElectricCar; newVehicle = newVehicle as ElectricCar; } } else if (i_VehicletoCreate == eVehicleType.Truck) { bool carryingToxic = (bool)i_UniqueParameter1; float loadVolume = (float)i_UniqueParameter2; Truck newTruck = new Truck(i_ModelName, i_LicenceID, carryingToxic, loadVolume, i_WheelsManfacturer, i_AmountOfCurrentEnergyLeft); newVehicle = newTruck; newVehicle = newVehicle as Truck; } else { throw new ArgumentException(); } if (newVehicle == null) { throw new FormatException(); } return(newVehicle); }
public CreateVehicle(Vehicle i_Vehicle) { vehicle = i_Vehicle; normalCar = new NormalCar(vehicle); electricCar = new ElectricCar(vehicle); normalMotorcycle = new NormalMotorcycle(vehicle); electricMotorcycle = new ElectricMotorcycle(vehicle); truck = new Truck(vehicle); GetDataFromUser(); }
public static Vehicles CreatElectricCar(int i_AmountOfDoors, float i_BatteryTimeremainingInhours, Car.eColor i_ColorOfCar , string i_ModelName, string i_LicenseNumber, float i_PercentageOfEnergyRemainingInItsEnergysource, float i_CurrentAirPressur, String i_WheelManufacturerName) { ElectricCar NewElectricCar = new ElectricCar(i_AmountOfDoors, i_BatteryTimeremainingInhours, i_ColorOfCar , i_ModelName, i_LicenseNumber, i_PercentageOfEnergyRemainingInItsEnergysource, i_CurrentAirPressur, i_WheelManufacturerName); return(NewElectricCar); }
private bool handleBatteryTimeSpan(string i_Answer, Vehicle i_VehicleInSetting) { bool succeed = true; ElectricCar electricVehicle = i_VehicleInSetting as ElectricCar; ElectricMotorcycle electricMotorcycle = i_VehicleInSetting as ElectricMotorcycle; if (electricVehicle != null) { succeed = float.TryParse(i_Answer, out float batteryCapacity); if (succeed) { try { electricVehicle.MaximalBatteryTime = batteryCapacity; electricVehicle.BatteryTimeLeft = batteryCapacity / 2; } catch { succeed = false; } } else { succeed = false; } } if (electricMotorcycle != null) { succeed = float.TryParse(i_Answer, out float batteryCapacity); if (succeed) { try { electricMotorcycle.MaximalBatteryTime = batteryCapacity; electricMotorcycle.BatteryTimeLeft = batteryCapacity / 2; } catch { succeed = false; } } else { succeed = false; } } return(succeed); }
public static Vehicle CreateElectricCar(Vehicle.BasicInformationOfVehicleAndOwner informationOfVehicleAndOwner, Car.e_Color i_color, Car.e_NumberOfDoors i_numberOfDoors) { Vehicle electricCar = new ElectricCar( informationOfVehicleAndOwner.m_ModelName, informationOfVehicleAndOwner.m_LicenseNumber, informationOfVehicleAndOwner.m_WheelManufacturer, informationOfVehicleAndOwner.m_CurrentAirPressure, informationOfVehicleAndOwner.m_AmountEnergyResource, i_color, i_numberOfDoors); return(electricCar); }
public static Vehicle MakeNewVehicle(eVehicle i_TypeToCreate, string i_ModelName, string i_LicensePlateNumber, out List <string> o_QuestionsToAsk, out List <string> o_Attributes) { switch (i_TypeToCreate) { case eVehicle.ElectricCar: { o_QuestionsToAsk = ElectricCar.GetQuestions(); o_Attributes = ElectricCar.GetAtributes(); return(new ElectricCar(i_ModelName, i_LicensePlateNumber, 4, 32, 2.1f)); } case eVehicle.FuelCar: { o_QuestionsToAsk = FuelCar.GetQuestions(); o_Attributes = FuelCar.GetAtributes(); return(new FuelCar(i_ModelName, i_LicensePlateNumber, 4, 32, FuelVehicle.eFuel.Octan96, 60)); } case eVehicle.ElectricMotorcycle: { o_QuestionsToAsk = ElectricMotorcycle.GetQuestions(); o_Attributes = ElectricMotorcycle.GetAtributes(); return(new ElectricMotorcycle(i_ModelName, i_LicensePlateNumber, 2, 30, 1.2f)); } case eVehicle.FuelMotorcycle: { o_QuestionsToAsk = FuelMotorcycle.GetQuestions(); o_Attributes = FuelMotorcycle.GetAtributes(); return(new FuelMotorcycle(i_ModelName, i_LicensePlateNumber, 2, 30, FuelVehicle.eFuel.Octan95, 7)); } case eVehicle.Truck: { o_QuestionsToAsk = Truck.GetQuestions(); o_Attributes = Truck.GetAtributes(); return(new Truck(i_ModelName, i_LicensePlateNumber, 16, 28, FuelVehicle.eFuel.Soler, 120)); } default: { o_QuestionsToAsk = null; o_Attributes = null; return(null); } } }
public static Vehicle MakeVehicle(eVehicleType i_VehicleType, List <object> i_Values) { Vehicle vehicle = null; switch (i_VehicleType) { case eVehicleType.ElectricBike: { vehicle = new ElectricBike(i_Values[0].ToString(), i_Values[1].ToString(), i_Values[4].ToString(), (float)i_Values[5], (eLicenseType)i_Values[6], (int)i_Values[7]); break; } case eVehicleType.FuelBike: { vehicle = new FuelBike(i_Values[0].ToString(), i_Values[1].ToString(), i_Values[4].ToString(), (float)i_Values[5], (eLicenseType)i_Values[6], (int)i_Values[7]); break; } case eVehicleType.ElectricCar: { vehicle = new ElectricCar(i_Values[0].ToString(), i_Values[1].ToString(), i_Values[4].ToString(), (float)i_Values[5], (eCarColor)i_Values[6], (eNumOfDoors)i_Values[7]); break; } case eVehicleType.FuelCar: { vehicle = new FuelCar(i_Values[0].ToString(), i_Values[1].ToString(), i_Values[4].ToString(), (float)i_Values[5], (eCarColor)i_Values[6], (eNumOfDoors)i_Values[7]); break; } case eVehicleType.Truck: { vehicle = new Truck(i_Values[0].ToString(), i_Values[1].ToString(), i_Values[4].ToString(), (float)i_Values[5], (bool)i_Values[6], (float)i_Values[7]); break; } } return(vehicle); }
public static Vehicle CreateVehicle(Utilities.eTypeOfVehicle i_VehicleType, string i_ModelName, string i_NumberOfCarLicense, string i_NameOfManufacturer, float i_CurTirePressure) { Vehicle createdVehicle = null; switch (i_VehicleType) { case Utilities.eTypeOfVehicle.ElectricCar: { createdVehicle = new ElectricCar(i_ModelName, i_NumberOfCarLicense, i_NameOfManufacturer, i_CurTirePressure); break; } case Utilities.eTypeOfVehicle.ElectricMotorcycle: { createdVehicle = new ElectricMotorcycle(i_ModelName, i_NumberOfCarLicense, i_NameOfManufacturer, i_CurTirePressure); break; } case Utilities.eTypeOfVehicle.FuelBasedCar: { createdVehicle = new FuelBasedCar(i_ModelName, i_NumberOfCarLicense, i_NameOfManufacturer, i_CurTirePressure); break; } case Utilities.eTypeOfVehicle.FuelBasedMotorcycle: { createdVehicle = new FuelBasedMotorcycle(i_ModelName, i_NumberOfCarLicense, i_NameOfManufacturer, i_CurTirePressure); break; } case Utilities.eTypeOfVehicle.FuelBasedTruck: { createdVehicle = new FuelBasedTruck(i_ModelName, i_NumberOfCarLicense, i_NameOfManufacturer, i_CurTirePressure); break; } default: { throw new ArgumentException("Please enter a valid vehicle"); } } return(createdVehicle); }
// check if the garage can handle with that king of vehicle private bool checkValidVehicle(Vehicle i_Vehicle) { bool validFuelCar = false, validElectronicCar = false, validFuelMotor = false, validElectronicMotor = false, validTruck = false; FuelBaseCar fuelBaseCar = i_Vehicle as FuelBaseCar; ElectricCar electronicCar = i_Vehicle as ElectricCar; FuelBaseMotorcycle fuelBaseMotorcycle = i_Vehicle as FuelBaseMotorcycle; ElectricMotorcycle electronicMotorcycle = i_Vehicle as ElectricMotorcycle; Truck truck = i_Vehicle as Truck; if (fuelBaseCar != null) { validFuelCar = checkFuelBaseVehicleValid( fuelBaseCar, r_FuelTypeGarageSupportForCarList, r_MaxFuelTankGarageSupportForFuelCarList, r_NumOfWheelsGarageSupportForCarList, r_MaxAirPressureGarageSupportForCarList); } else if (electronicCar != null) { validElectronicCar = checkElectronicVehicleValid( electronicCar, r_MaxBatteryTimeGarageSupportForElectricCarList, r_NumOfWheelsGarageSupportForCarList, r_MaxAirPressureGarageSupportForCarList); } else if (fuelBaseMotorcycle != null) { validFuelMotor = checkFuelBaseVehicleValid( fuelBaseMotorcycle, r_FuelTypeGarageSupportForMotorList, r_MaxFuelTankGarageSupportForFuelMotorList, r_NumOfWheelsGarageSupportForMotorList, r_MaxAirPressureGarageSupportForMotorList); } else if (electronicMotorcycle != null) { validElectronicMotor = checkElectronicVehicleValid( electronicMotorcycle, r_MaxBatteryTimeGarageSupportForElectricMotorList, r_NumOfWheelsGarageSupportForMotorList, r_MaxAirPressureGarageSupportForMotorList); } else if (truck != null) { validTruck = checkFuelBaseVehicleValid( truck, r_FuelTypeGarageSupportForTruckList, r_MaxFuelTankGarageSupportForTruckList, r_NumOfWheelsGarageSupportForTruckList, r_MaxAirPressureGarageSupportForTruckList); } return(validFuelCar || validElectronicCar || validFuelMotor || validElectronicMotor || validTruck); }
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); }
public static Vehicle CreateNewElectricCar( string i_ModelName, string i_LicenseNumber, string[] i_ManufacturerNamesOfAllTires, float[] i_CurrentPressureOfAllTires, float i_RemainingBatteryTime, Car.eDoorCount i_DoorsAmount, Car.eColor i_Color) { Vehicle vehicle = new ElectricCar( i_ModelName, i_LicenseNumber, i_ManufacturerNamesOfAllTires, i_CurrentPressureOfAllTires, i_RemainingBatteryTime, i_DoorsAmount, i_Color); return(vehicle); }
public void SetCarAdditionalParams(string i_LicenseNumber, int i_VehicleColor, int i_NumOfDoors) { GarageVehicle garageVehicle = VehiclesInGarage[i_LicenseNumber]; eColors color = checkIfValidColorParam(i_VehicleColor); eDoors numOfDoors = checkIfValidDoorsParam(i_NumOfDoors); if (garageVehicle.Vehicle is FuelCar) { FuelCar fuelCar = garageVehicle.Vehicle as FuelCar; fuelCar.CarDetails.VehicleColor = color; fuelCar.CarDetails.NumOfDoors = numOfDoors; } else if (garageVehicle.Vehicle is ElectricCar) { ElectricCar electricCar = garageVehicle.Vehicle as ElectricCar; electricCar.CarDetails.VehicleColor = color; electricCar.CarDetails.NumOfDoors = numOfDoors; } }
private bool handleCarDoorNumber(string i_Answer, Vehicle i_VehicleInSetting) { bool succeed = byte.TryParse(i_Answer, out byte doorNumberInByte); ElectricCar electricCar = i_VehicleInSetting as ElectricCar; FuelBaseCar fuelCar = i_VehicleInSetting as FuelBaseCar; eDoorsNumber doorNumber = ElectricCar.CovertNumToDoorNumber(doorNumberInByte); if (succeed && fuelCar != null) { try { fuelCar.DoorsNumber = doorNumber; succeed = true; } catch { succeed = false; } } else if (succeed && electricCar != null) { try { electricCar.DoorsNumber = doorNumber; succeed = true; } catch { succeed = false; } } else { succeed = false; } return(succeed); }