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 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 CreateNewElectricBike( string i_ModelName, string i_LicenseNumber, string[] i_ManufacturerNamesOfAllTires, float[] i_CurrentPressureOfAllTires, float i_RemainingBatteryTime, Bike.eLicense i_RequiredLicense, int i_EngineVolume) { Vehicle vehicle = new ElectricBike( i_ModelName, i_LicenseNumber, i_ManufacturerNamesOfAllTires, i_CurrentPressureOfAllTires, i_RemainingBatteryTime, i_RequiredLicense, i_EngineVolume); return(vehicle); }
public Vehicle CreateVehicle(GeneralRequest generalRequest, object vehicleRequest, bool IsElectric) { const float electricCarMaxEnergyLevel = 4.8f; const float electricBikeMaxEnergyLevel = 3.2f; const float liquidFuelBikeMaxEnergyLevel = 5f; const float liquidFuelCarMaxEnergyLevel = 48f; const float truckMaxEnergyLevel = 105f; float remainadEnergy = generalRequest.EnergyRemained; Vehicle vehicle = null; if (vehicleRequest.GetType().Name == "CarRequest") { if (IsElectric) { vehicle = new ElectricCar(generalRequest, (CarRequest)vehicleRequest, CurrentEnergyLevel(electricCarMaxEnergyLevel, remainadEnergy), electricCarMaxEnergyLevel); } else { vehicle = new LiquidFuelCar(generalRequest, (CarRequest)vehicleRequest, CurrentEnergyLevel(liquidFuelCarMaxEnergyLevel, remainadEnergy), liquidFuelCarMaxEnergyLevel); } } else if (vehicleRequest.GetType().Name == "BikeRequest") { if (IsElectric) { vehicle = new ElectricBike(generalRequest, (BikeRequest)vehicleRequest, CurrentEnergyLevel(electricBikeMaxEnergyLevel, remainadEnergy), electricBikeMaxEnergyLevel); } else { vehicle = new LiquidFuelBike(generalRequest, (BikeRequest)vehicleRequest, CurrentEnergyLevel(liquidFuelBikeMaxEnergyLevel, remainadEnergy), liquidFuelBikeMaxEnergyLevel); } } else if (vehicleRequest.GetType().Name == "TruckRequest") { vehicle = new Truck(generalRequest, (TruckRequest)vehicleRequest, CurrentEnergyLevel(truckMaxEnergyLevel, remainadEnergy), truckMaxEnergyLevel); } return(vehicle); }
/*7. Display vehicle information (License number, Model name, Owner name, Status in * garage, Tire specifications(manufacturer and air pressure), Fuel status + Fuel type * Battery status, other relevant information based on vehicle type)*/ public List <object> GetFullVehicleDetails(string i_LicenseNumber) { List <object> fullDetails = new List <object>(); eVehicleType vehicleType = GetVehicleTypeByLicenseNumber(i_LicenseNumber); Vehicle currentVehicle = GetVehicleByLicense(i_LicenseNumber); VehicleInfo currentVehicleInfo = GetVehicleInfoByLicense(i_LicenseNumber); fullDetails.Add(vehicleType); fullDetails.Add(currentVehicle.LicenseNumber); fullDetails.Add(currentVehicle.ModelName); fullDetails.Add(currentVehicleInfo.OwnerName); fullDetails.Add(currentVehicleInfo.OwnerPhoneNumber); fullDetails.Add(currentVehicleInfo.Status); fullDetails.Add(currentVehicle.Wheels[0].MaxAirPressure); switch (vehicleType) { case eVehicleType.ElectricBike: { ElectricBike electricBike = (ElectricBike)currentVehicle; fullDetails.Add(electricBike.LicenseType); fullDetails.Add(electricBike.EngineCCVolume); fullDetails.Add(electricBike.MaximalBatteryTime); fullDetails.Add(electricBike.RemainingBatteryTime); for (int i = 0; i < electricBike.Wheels.Count; i++) { fullDetails.Add(electricBike.Wheels[i].CurrentAirPressure); fullDetails.Add(electricBike.Wheels[i].ManufacturerName); } break; } case eVehicleType.ElectricCar: { ElectricCar electricCar = (ElectricCar)currentVehicle; fullDetails.Add(electricCar.CarColor); fullDetails.Add(electricCar.NumOfDoors); fullDetails.Add(electricCar.MaximalBatteryTime); fullDetails.Add(electricCar.RemainingBatteryTime); for (int i = 0; i < electricCar.Wheels.Count; i++) { fullDetails.Add(electricCar.Wheels[i].CurrentAirPressure); fullDetails.Add(electricCar.Wheels[i].ManufacturerName); } break; } case eVehicleType.FuelBike: { FuelBike fuelBike = (FuelBike)currentVehicle; fullDetails.Add(fuelBike.LicenseType); fullDetails.Add(fuelBike.EngineCCVolume); fullDetails.Add(fuelBike.EnergyType); fullDetails.Add(fuelBike.MaximalFuelLevel); fullDetails.Add(fuelBike.CurrentFuelLevel); for (int i = 0; i < fuelBike.Wheels.Count; i++) { fullDetails.Add(fuelBike.Wheels[i].CurrentAirPressure); fullDetails.Add(fuelBike.Wheels[i].ManufacturerName); } break; } case eVehicleType.FuelCar: { FuelCar fuelCar = (FuelCar)currentVehicle; fullDetails.Add(fuelCar.CarColor); fullDetails.Add(fuelCar.NumOfDoors); fullDetails.Add(fuelCar.EnergyType); fullDetails.Add(fuelCar.MaximalFuelLevel); fullDetails.Add(fuelCar.CurrentFuelLevel); for (int i = 0; i < fuelCar.Wheels.Count; i++) { fullDetails.Add(fuelCar.Wheels[i].CurrentAirPressure); fullDetails.Add(fuelCar.Wheels[i].ManufacturerName); } break; } case eVehicleType.Truck: { Truck truck = (Truck)currentVehicle; fullDetails.Add(truck.MaximalFuelLevel); fullDetails.Add(truck.CurrentFuelLevel); fullDetails.Add(truck.EnergyType); fullDetails.Add(truck.IsCarryingHazards); fullDetails.Add(truck.MaxLoadAllowed); for (int i = 0; i < truck.Wheels.Count; i++) { fullDetails.Add(truck.Wheels[i].CurrentAirPressure); fullDetails.Add(truck.Wheels[i].ManufacturerName); } break; } default: { break; } } return(fullDetails); }