private void addTruck(string i_Name, string i_Phone, string i_Plate, string i_VehicleModel) { HoldWheelParams wheels = getWheelParams(SupportedParameters.k_MaxTruckWheelPressure, (uint)eNumOfWheels.TwelveWheeledTruck); HoldEngineParams engine = getEngine(eEngineEnergyTypes.Soler, SupportedParameters.k_MaxTruckFuelTank, k_FuelAmountFormat); float isRegregerated = -1; bool tryParse = false; float trunkVolume = 0; while ((!tryParse) || (isRegregerated > 1) || (isRegregerated < 0)) { Console.WriteLine(@"Is the Refrigerated? Type '1' for Yes: Type '0' or No"); tryParse = float.TryParse(Console.ReadLine(), out isRegregerated); } tryParse = false; while ((!tryParse) || (trunkVolume < 0)) { Console.WriteLine("Enter Trunk Volume in m^3"); tryParse = float.TryParse(Console.ReadLine(), out trunkVolume); } try { HoldAddGarageVehicleParams garageParams = new HoldAddGarageVehicleParams(i_Name, i_Phone, i_VehicleModel, i_Plate, wheels, engine, Garage.eVehicleStatus.Repairing, eVehicleTypes.Truck); m_Grage.AddVehicleToGarage(garageParams, (float)isRegregerated, (float)trunkVolume); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void addCar(string i_Name, string i_Phone, string i_Plate, string i_VehicleModel, eEngineEnergyTypes i_EngineType, float i_MaxEnergy, string i_EnergyFormat) { HoldWheelParams wheels = getWheelParams(SupportedParameters.k_MaxCarWheelPressure, (uint)eNumOfWheels.FourWheeledCar); HoldEngineParams engine = getEngine(i_EngineType, i_MaxEnergy, i_EnergyFormat); Car.eColors color; Car.eNumOfDoors numOfDoors; int numberOfOptions = Enum.GetNames(typeof(Car.eColors)).Length; int userInput = -1; bool tryParse = false; while ((!tryParse) || (userInput > numberOfOptions) || (userInput < 1)) { Console.WriteLine("Choose a Color:"); foreach (Car.eColors colorsType in Enum.GetValues(typeof(Car.eColors))) { Console.WriteLine("{0}. {1}", (int)colorsType, colorsType.ToString()); } tryParse = int.TryParse(Console.ReadLine(), out userInput); } color = (Car.eColors)userInput; numberOfOptions = Enum.GetNames(typeof(Car.eNumOfDoors)).Length; userInput = -1; tryParse = false; while ((!tryParse) || (userInput > numberOfOptions) || (userInput < 1)) { Console.WriteLine("Choose Number of Doors:"); foreach (Car.eNumOfDoors doorsType in Enum.GetValues(typeof(Car.eNumOfDoors))) { Console.WriteLine("{0}. {1}", (int)doorsType, doorsType.ToString()); } tryParse = int.TryParse(Console.ReadLine(), out userInput); } numOfDoors = (Car.eNumOfDoors)userInput; try { HoldAddGarageVehicleParams garageParams = new HoldAddGarageVehicleParams(i_Name, i_Phone, i_VehicleModel, i_Plate, wheels, engine, Garage.eVehicleStatus.Repairing, eVehicleTypes.Car); m_Grage.AddVehicleToGarage(garageParams, (float)color, (float)numOfDoors); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void addMotorcycle(string i_Name, string i_Phone, string i_Plate, string i_VehicleModel, eEngineEnergyTypes i_EngineType, float i_MaxEnergy, string i_EnergyFormat) { HoldWheelParams wheels = getWheelParams(SupportedParameters.k_MaxMotorcycleWheelPressure, (uint)eNumOfWheels.TwoWheeledMotorcycle); HoldEngineParams engine = getEngine(i_EngineType, i_MaxEnergy, i_EnergyFormat); Motorcycle.eMotorcycleLicenceType license; int numberOfOptions = Enum.GetNames(typeof(Motorcycle.eMotorcycleLicenceType)).Length; int userInput = -1; bool tryParse = false; float engineVolume = 0; try { while ((!tryParse) || (userInput > numberOfOptions) || (userInput < 1)) { Console.WriteLine("Choose a License Type:"); foreach (Motorcycle.eMotorcycleLicenceType licenseType in Enum.GetValues(typeof(Motorcycle.eMotorcycleLicenceType))) { Console.WriteLine("{0}. {1}", (int)licenseType, licenseType.ToString()); } tryParse = int.TryParse(Console.ReadLine(), out userInput); } license = (Motorcycle.eMotorcycleLicenceType)userInput; tryParse = false; while (!tryParse) { Console.WriteLine("Enter Engine Volume"); tryParse = float.TryParse(Console.ReadLine(), out engineVolume); } HoldAddGarageVehicleParams garageParams = new HoldAddGarageVehicleParams(i_Name, i_Phone, i_VehicleModel, i_Plate, wheels, engine, Garage.eVehicleStatus.Repairing, eVehicleTypes.Motorcycle); m_Grage.AddVehicleToGarage(garageParams, (float)engineVolume, (float)license); } catch (Exception ex) { throw ex; } }
private HoldWheelParams getWheelParams(float i_MaxManufacturerPressure, uint i_NumOfWheels) { bool tryParse = false; float wheelPressureStatus = -1; HoldWheelParams wheelParams = null; try { string wheelManufacturerName = getSomeName("Enter wheel manufacturer name:"); while (!tryParse || wheelPressureStatus < 0 || wheelPressureStatus > i_MaxManufacturerPressure) { Console.WriteLine("Enter wheel pressure status, should be between [0, {0}]:", i_MaxManufacturerPressure); tryParse = float.TryParse(Console.ReadLine(), out wheelPressureStatus); } wheelParams = new HoldWheelParams(wheelManufacturerName, i_MaxManufacturerPressure, i_NumOfWheels, wheelPressureStatus); } catch (Exception ex) { throw ex; } return(wheelParams); }