// $G$ DSN-011 (-8) The component who responsible for creating vehicles, should be in a separate component. private Vehicle createNewVehicle(string i_LicensePlate, string i_ModelName, string i_WheelManufacturer, out string o_OwnerName, out string o_OwnerPhone) { Vehicle newVehicle; Vehicle.eTypeOfVehicle vehicleType, vehicleOptions = new Vehicle.eTypeOfVehicle(); EnergySource.eSource vehicleEnergySource; EnergySource.eSource energySourceOptions = new EnergySource.eSource(); string PartOfOptionsHeaderMsg = string.Format("vehicle type"); o_OwnerName = m_InputUI.GetOwnerNameFromUser(); o_OwnerPhone = m_InputUI.GetOwnerPhoneFromUser(); vehicleType = (Vehicle.eTypeOfVehicle)m_InputUI.MakeArrayOfStringFromEnum(PartOfOptionsHeaderMsg, vehicleOptions); PartOfOptionsHeaderMsg = string.Format("energy source"); if (vehicleType != Vehicle.eTypeOfVehicle.Truck) { vehicleEnergySource = (EnergySource.eSource)m_InputUI.MakeArrayOfStringFromEnum(PartOfOptionsHeaderMsg, energySourceOptions); } else { vehicleEnergySource = EnergySource.eSource.FuelSource; } newVehicle = CreateVehicle.CreateNewVehicle(vehicleType, vehicleEnergySource, i_LicensePlate, i_ModelName, i_WheelManufacturer); insertVehicleDetails(newVehicle); return(newVehicle); }
private Vehicle createNewVehicle( string i_LicensePlate, string i_ModelName, string i_WheelManufacturer, out string o_OwnerName, out string o_OwnerPhone) { Vehicle newVehicle; Vehicle.eType vehicleType, vehicleOptions = new Vehicle.eType(); EnergySource.eSource vehicleEnergySource; EnergySource.eSource energySourceOptions = new EnergySource.eSource(); string PartOfOptionsHeaderMsg = string.Format("vehicle type"); o_OwnerName = UI.GetOwnerName(); o_OwnerPhone = UI.GetOwnerPhone(); vehicleType = (Vehicle.eType)UI.GetSpecificEnumInput(PartOfOptionsHeaderMsg, vehicleOptions); PartOfOptionsHeaderMsg = string.Format("energy source"); if (vehicleType != Vehicle.eType.Truck) { vehicleEnergySource = (EnergySource.eSource)UI.GetSpecificEnumInput(PartOfOptionsHeaderMsg, energySourceOptions); } else { vehicleEnergySource = EnergySource.eSource.GasTank; } newVehicle = VehicleFactory.CreateVehicle(vehicleType, vehicleEnergySource, i_LicensePlate, i_ModelName, i_WheelManufacturer); insertVehicleDetails(newVehicle); return(newVehicle); }
public static Vehicle CreateVehicle( Vehicle.eType i_TypeOfVehicle, EnergySource.eSource i_SourceOfEnergy, string i_LicensePlate, string i_ModelName, string i_WheelManufacturer) { Vehicle result = null; switch (i_TypeOfVehicle) { case Vehicle.eType.Motorcycle: result = new Motorcycle(i_LicensePlate, i_ModelName, i_WheelManufacturer, i_SourceOfEnergy); break; case Vehicle.eType.Car: result = new Car(i_LicensePlate, i_ModelName, i_WheelManufacturer, i_SourceOfEnergy); break; case Vehicle.eType.Truck: result = new Truck(i_LicensePlate, i_ModelName, i_WheelManufacturer, i_SourceOfEnergy); break; } return(result); }
public Vehicle(string i_LicensePlate, string i_ModelName, EnergySource.eSource i_Source) { m_ModelName = i_ModelName; m_LicensePlate = i_LicensePlate; m_Wheels = new List <Wheel>(); if (i_Source == EnergySource.eSource.Battery) { m_EnergySource = new Battery(); } else { m_EnergySource = new GasTank(); } }
public Vehicle(string i_ModelName, string i_LicensePlate, EnergySource.eSource i_Source) { m_ModelName = i_ModelName; m_LicenseNumber = i_LicensePlate; m_Wheels = new List <Wheel>(); if (i_Source == EnergySource.eSource.ElectricSource) { m_EnergySource = new ElectricSource(); } else { m_EnergySource = new FuelSource(); } }
public Truck(string i_LicenseNumber, string i_ModelName, string i_WheelManufacturerName, EnergySource.eSource i_energySource) : base(i_ModelName, i_LicenseNumber, i_energySource) { for (int i = 0; i < k_QuantityOfWheels; i++) { Wheels.Add(new Wheel(i_WheelManufacturerName, (float)Wheel.eMaxAirPressure.Truck)); } SetEnergySource(); }
public Motorcycle(string i_LicensePlate, string i_ModelName, string i_WheelManufacturer, EnergySource.eSource i_Source) : base(i_LicensePlate, i_ModelName, i_Source) { for (int i = 0; i < k_AmountOfWheels; i++) { Wheels.Add(new Wheel(i_WheelManufacturer, (float)Wheel.eMaxAirPressure.Motorcycle)); } InitializeEnergySource(); }
public static Vehicle CreateNewVehicle(Vehicle.eTypeOfVehicle i_TypeOfVehicle, EnergySource.eSource i_SourceOfEnergy, string i_LicenseNumber, string i_ModelName, string i_WheelManufacturerName) { Vehicle newVehicle = null; if (Vehicle.eTypeOfVehicle.Motorcycle == i_TypeOfVehicle) { newVehicle = new Motorcycle(i_LicenseNumber, i_ModelName, i_WheelManufacturerName, i_SourceOfEnergy); } if (Vehicle.eTypeOfVehicle.Car == i_TypeOfVehicle) { newVehicle = new Car(i_LicenseNumber, i_ModelName, i_WheelManufacturerName, i_SourceOfEnergy); } if (Vehicle.eTypeOfVehicle.Truck == i_TypeOfVehicle) { newVehicle = new Truck(i_LicenseNumber, i_ModelName, i_WheelManufacturerName, i_SourceOfEnergy); } return(newVehicle); }