private static FuelMotorcycle initNewFuelMotorcycle(string i_LicensePlateSrting, string i_VehicleModel, float i_EnergyLeft, string i_WheelManufacturer, float i_WheelCurrentAirPressure, string[] i_Parameters) { const bool v_IgnoreCase = true; const float k_MaxAirPressureInFuelMotorcycleWheels = 34; const FuelEngine.eFuelType k_SupportedMotorcycleFuelType = FuelEngine.eFuelType.Octan98; const float k_MaxMotorcycleFuelTank = 8; if (i_EnergyLeft > k_MaxMotorcycleFuelTank) { throw new ValueOutOfRangeException(k_MaxMotorcycleFuelTank); } int engineVolume = int.Parse(i_Parameters[1]); FuelEngine engine = new FuelEngine(k_MaxMotorcycleFuelTank, i_EnergyLeft, engineVolume, k_SupportedMotorcycleFuelType); if (i_WheelCurrentAirPressure > k_MaxAirPressureInFuelMotorcycleWheels) { throw new ValueOutOfRangeException(k_MaxAirPressureInFuelMotorcycleWheels); } List <Wheel> wheels = new List <Wheel>(k_NumberOfWheelsInMotorcycle); for (int i = 0; i < k_NumberOfWheelsInMotorcycle; i++) { wheels.Add(new Wheel(i_WheelManufacturer, i_WheelCurrentAirPressure, k_MaxAirPressureInFuelMotorcycleWheels)); } Motorcycle.eLicenseType licenseType = (Motorcycle.eLicenseType)Enum.Parse(typeof(Motorcycle.eLicenseType), i_Parameters[0], v_IgnoreCase); return(new FuelMotorcycle(i_LicensePlateSrting, i_VehicleModel, wheels, licenseType, engine)); }
public static Vehicles CreateElectricMotorsycleObject() { float PercentageOfEnergyRemainingInItsEnergysource = 0, CurrentAirPressur = 0, BatteryTimeremainingInhours = 0; string LicenseNumber = "", ModelName = "", WheelManufacturerName = ""; Motorcycle.eLicenseType LicenseType = 0; int EngineVolumeInCc = 0; Vehicles NewElectricMotorcycel; GetNewVehiclePharameter(ref LicenseNumber, ref ModelName, ref PercentageOfEnergyRemainingInItsEnergysource, ref CurrentAirPressur, ref WheelManufacturerName); if (CurrentAirPressur > Motorcycle.MotorcycleWheelsMaxAirPressure || CurrentAirPressur < 0) { throw new ValueOutOfRangeException(Motorcycle.MotorcycleWheelsMaxAirPressure, 0); } GetMotorcyclePharameter(ref EngineVolumeInCc, ref LicenseType); GetElectricVehiclesPharameter(ref BatteryTimeremainingInhours); if (BatteryTimeremainingInhours > ElectricMotorcycel.MaximumBatteryInHours || BatteryTimeremainingInhours < 0) { throw new ValueOutOfRangeException(ElectricMotorcycel.MaximumBatteryInHours, 0); } NewElectricMotorcycel = CreatNewObject.CreatElectricMotorcycel(LicenseType, BatteryTimeremainingInhours, EngineVolumeInCc, ModelName, LicenseNumber, PercentageOfEnergyRemainingInItsEnergysource, WheelManufacturerName, CurrentAirPressur); return(NewElectricMotorcycel); }
private void insertMotorcycle() { string modelName = getModelName(); string licenseNumber = getLicenseNumber(); Factory.eEnergyType energyType = GetEnergyType(); EnergyStorage energyStorage = Factory.GenerateEnergyStorage(Factory.eVehicleType.Motorcycle, energyType); float energyPercentage = getEnergyPercentage(); List <Tire> wheels = insertWheels(Factory.eVehicleType.Motorcycle, k_MotorcycleWheelsAmount); Motorcycle.eLicenseType licenseType = getLicenseType(); int engineCapacity = getEngineCapacity(); Motorcycle motorcycle = Factory.GenerateMotorcycle(modelName, licenseNumber, wheels, energyStorage, licenseType, engineCapacity, energyPercentage); try { r_GarageLogic.InsertVehicleToGarage(getOwnerDetails(motorcycle)); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message); Console.ResetColor(); } }
private static Vehicles CreateGasMotorcycleObject() { float PercentageOfEnergyRemainingInItsEnergysource = 0, FuelPresentInLiters = 0, CurrentAirPressur = 0; string LicenseNumber = "", ModelName = "", WheelManufacturerName = ""; Motorcycle.eLicenseType LicenseType = 0; int EngineVolumeInCc = 0; Vehicles NewGasMotorcycel; GetNewVehiclePharameter(ref LicenseNumber, ref ModelName, ref PercentageOfEnergyRemainingInItsEnergysource, ref CurrentAirPressur, ref WheelManufacturerName); if (CurrentAirPressur > Motorcycle.MotorcycleWheelsMaxAirPressure || CurrentAirPressur < 0) { throw new ValueOutOfRangeException(Motorcycle.MotorcycleWheelsMaxAirPressure, 0); } GetGasVehiclesPharameter(ref FuelPresentInLiters); if (FuelPresentInLiters > MotorcycelWorkingOnGas.MaximumAmountOfFuelInLiters || FuelPresentInLiters < 0) { throw new ValueOutOfRangeException(MotorcycelWorkingOnGas.MaximumAmountOfFuelInLiters, 0); } GetMotorcyclePharameter(ref EngineVolumeInCc, ref LicenseType); NewGasMotorcycel = CreatNewObject.CreatGasMotorcycel(FuelPresentInLiters, LicenseType, EngineVolumeInCc, ModelName, LicenseNumber, PercentageOfEnergyRemainingInItsEnergysource, WheelManufacturerName, CurrentAirPressur); return(NewGasMotorcycel); }
private static ElectricMotorcycle initNewElectricMotorcycle(string i_LicensePlateSrting, string i_VehicleModel, float i_EnergyLeft, string i_WheelManufacturer, float i_WheelCurrentAirPressure, string[] i_Parameters) { const bool v_IgnoreCase = true; const float k_MaxAirPressureInElectricMotorcycleWheels = 31; const float k_MaxMotorcycleHoursInBattery = 1.2f; if (i_EnergyLeft > k_MaxMotorcycleHoursInBattery) { throw new ValueOutOfRangeException(k_MaxMotorcycleHoursInBattery); } int engineVolume = int.Parse(i_Parameters[1]); ElectricEngine engine = new ElectricEngine(k_MaxMotorcycleHoursInBattery, i_EnergyLeft, engineVolume); if (i_WheelCurrentAirPressure > k_MaxAirPressureInElectricMotorcycleWheels) { throw new ValueOutOfRangeException(k_MaxAirPressureInElectricMotorcycleWheels); } List <Wheel> wheels = new List <Wheel>(k_NumberOfWheelsInMotorcycle); for (int i = 0; i < k_NumberOfWheelsInMotorcycle; i++) { wheels.Add(new Wheel(i_WheelManufacturer, i_WheelCurrentAirPressure, k_MaxAirPressureInElectricMotorcycleWheels)); } Motorcycle.eLicenseType licenseType = (Motorcycle.eLicenseType)Enum.Parse(typeof(Motorcycle.eLicenseType), i_Parameters[0], v_IgnoreCase); return(new ElectricMotorcycle(i_LicensePlateSrting, i_VehicleModel, wheels, licenseType, engine)); }
public static Vehicles CreatElectricMotorcycel(Motorcycle.eLicenseType i_LicenseType, float i_BatteryTimeremainingInhours, int i_EngineVolumeInCc, string i_ModelName, string i_LicenseNumber, float i_PercentageOfEnergyRemainingInItsEnergysource, string i_WheelManufacturerName, float i_CurrentAirPressur) { ElectricMotorcycel NewElectricMotorcycel = new ElectricMotorcycel(i_LicenseType, i_BatteryTimeremainingInhours, i_EngineVolumeInCc, i_ModelName, i_LicenseNumber, i_PercentageOfEnergyRemainingInItsEnergysource, i_WheelManufacturerName, i_CurrentAirPressur); return(NewElectricMotorcycel); }
private void insertLicenseType(Motorcycle i_NewMotorcycle) { int licenseType; Motorcycle.eLicenseType licenseOptions = new Motorcycle.eLicenseType(); string PartOfOptionsHeaderMsg = string.Format("license type"); licenseType = UI.GetSpecificEnumInput(PartOfOptionsHeaderMsg, licenseOptions); i_NewMotorcycle.LicenseType = (Motorcycle.eLicenseType)licenseType; }
private static Motorcycle createMotorcycle(ArgumentsCollection i_Arguments, Motor i_Motor) { string licensePlate = (string)i_Arguments[eArgumentKeys.LicensePlate].Response; string model = (string)i_Arguments[eArgumentKeys.Model].Response; Motorcycle.eLicenseType licenseType = (Motorcycle.eLicenseType)Enum.Parse(typeof(Motorcycle.eLicenseType), i_Arguments[eArgumentKeys.LicenseType].Response); int engineVolume = int.Parse(i_Arguments[eArgumentKeys.EngineVolume].Response); Wheel[] wheels = wheelsCollectionBuilder(i_Arguments, Motorcycle.k_NumberOfWheels, VehicleMaxConstantsCollection[eVehicleMaxConstantTypes.MotorcycleMaxWheelPressure]); return(new Motorcycle(i_Motor, wheels, VehicleMaxConstantsCollection[eVehicleMaxConstantTypes.MotorcycleMaxWheelPressure], licensePlate, model, licenseType, engineVolume)); }
private List <Object> getUniqueMotorCyclePropertiesListFromUser() { List <Object> uniqueMotorCyclePropertiesList = new List <Object>(); Motorcycle.eLicenseType licenseType = (Motorcycle.eLicenseType)getValidEnumOptionFromUser(k_MotorCycleLicenseType, new Motorcycle.eLicenseType()); int motorCapacity = int.Parse(getValidIntegerNumberAsStringFromUser(k_MotorCycleEngineCapacity)); uniqueMotorCyclePropertiesList.Add(licenseType); uniqueMotorCyclePropertiesList.Add(motorCapacity); return(uniqueMotorCyclePropertiesList); }
private static Motorcycle getMotorcycle(Dictionary <string, ArgumentConsumer> i_MotorcycleArguments, Engine i_Engine) { Motorcycle.eLicenseType licenseType = EnumUtils.GetStringAsEnum <Motorcycle.eLicenseType>( i_MotorcycleArguments[Keys.LicenseType].ValueFromUser); int engineVolume = int.Parse(i_MotorcycleArguments[Keys.EngineVolume].ValueFromUser); string licenseNumber = i_MotorcycleArguments[Keys.LicenseNumber].ValueFromUser; Collection <Tire> tires = makeTiresCollection(i_MotorcycleArguments, Motorcycle.GetNumberOfTires); Motorcycle motorcycle = new Motorcycle(licenseNumber, tires, i_Engine, licenseType, engineVolume); return(motorcycle); }
private static void GetMotorcyclePharameter(ref int io_EngineVolumeInCc, ref Motorcycle.eLicenseType io_LicenseType)//קליטת פרמטרים לאופנוע { string EngineVolumeInCc; Motorcycle.eLicenseType LicenseType; LicenseType = ChooseLicenseType(); Console.WriteLine("Please enter Engine Volume In Cc"); EngineVolumeInCc = Console.ReadLine(); if (!int.TryParse(EngineVolumeInCc, out io_EngineVolumeInCc)) { throw new FormatException(); } }
public static Motorcycle CreateMotorCycle(string i_LicensePlate, string i_Model, Dictionary <eVehicleData, string> i_DataMemory, Dictionary <Vehicle.eWheelData, string> i_Wheel, Energy.eEnergyType i_EnergyType) { checkNumericStrings(i_DataMemory[eVehicleData.EngineCapacity]); Motorcycle.eLicenseType licenceType = Motorcycle.parseLicenseType(i_DataMemory[eVehicleData.LicenceType]); int engineCapacity = int.Parse(i_DataMemory[eVehicleData.EngineCapacity]); Energy energyType = null; if (i_EnergyType == Energy.eEnergyType.Regular) { checkNumericStrings(i_DataMemory[eVehicleData.AmountOfFuelLeft]); energyType = new RegularEnergy(RegularEnergy.eFuelType.Octan95, float.Parse(i_DataMemory[eVehicleData.AmountOfFuelLeft]), k_RegularMotorcycleFullTank); } else if (i_EnergyType == Energy.eEnergyType.Electric) { checkNumericStrings(i_DataMemory[eVehicleData.HoursLeftInBattery]); energyType = new ElectricEnergy(float.Parse(i_DataMemory[eVehicleData.HoursLeftInBattery]), k_ElectricMotorcycleMaxBatteryHourTime); } return(new Motorcycle(licenceType, engineCapacity, i_Model, i_LicensePlate, i_Wheel, energyType)); }
private static void GetVehicleLicenseTypeFromUser(out Motorcycle.eLicenseType o_LicenseType) { int userChoice = 0; bool validInput = false; StringBuilder userPrompt = new StringBuilder(); userPrompt.Append(" ------------------------------------------" + Environment.NewLine); userPrompt.Append(" Please choose your vehicle's license type:" + Environment.NewLine); userPrompt.Append(" 1) A" + Environment.NewLine); userPrompt.Append(" 2) A1" + Environment.NewLine); userPrompt.Append(" 3) A2" + Environment.NewLine); userPrompt.Append(" 4) B" + Environment.NewLine); userPrompt.Append(" ------------------------------------------" + Environment.NewLine); Console.Write(userPrompt + Environment.NewLine); while (validInput == false) { try { validInput = GetValidIntFromUserInRange(out userChoice, 1, 4); } catch (FormatException) { Console.WriteLine("Error: Please enter a number."); } catch (ValueOutOfRangeException ex) { Console.WriteLine("Error: The choice number should be between " + ex.MinValue + " to " + ex.MaxValue); } catch (Exception ex) { Console.WriteLine("Unknown error occured: " + Environment.NewLine + ex.Message + Environment.NewLine); } } o_LicenseType = (Motorcycle.eLicenseType)userChoice; }
public static Vehicles CreatGasMotorcycel(float i_AmountOfFuelPresentInLiters, Motorcycle.eLicenseType i_LicenseType, int i_EngineVolumeInCc, string i_ModelName, string i_LicenseNumber, float i_PercentageOfEnergyRemainingInItsEnergysource, string i_WheelManufacturerName, float i_CurrentAirPressur) { MotorcycelWorkingOnGas CreatMotorcycelWorkingOnGas = new MotorcycelWorkingOnGas(i_AmountOfFuelPresentInLiters, i_LicenseType, i_EngineVolumeInCc, i_ModelName, i_LicenseNumber, i_PercentageOfEnergyRemainingInItsEnergysource, i_WheelManufacturerName, i_CurrentAirPressur); return(CreatMotorcycelWorkingOnGas); }
public static void AddNewMotorcycleCompleteInformation(string i_LicenseNumberForNewVehicle, string i_VehicleModel, float i_MaxEnergyLevel, float i_CurrentEnergyLevel, Motorcycle.eLicenseType i_MotorcycleLicenseType, int i_EngineCapacitiyCC, Engine.eFuelType i_EnergyType, string i_OwnerName, string i_OwnerPhoneNumber) { if (i_EnergyType == Engine.eFuelType.Electricity) { createdEngine = new ElectricEngine(i_MaxEnergyLevel); } else { createdEngine = new FuelEngine(i_MaxEnergyLevel, i_EnergyType); } createdEngine.CurrentEnergyStatus = i_CurrentEnergyLevel; createdVehicle = new Motorcycle(i_VehicleModel, i_LicenseNumberForNewVehicle, i_MotorcycleLicenseType, i_EngineCapacitiyCC, createdEngine); Garage.AddNewVehicle(i_LicenseNumberForNewVehicle, i_OwnerName, i_OwnerPhoneNumber, createdVehicle); }
public static Motorcycle GenerateMotorcycle(string i_ModelName, string i_LicenseNumber, List <Tire> i_Wheels, EnergyStorage i_EnergyStorage, Motorcycle.eLicenseType i_LicenseType, int i_EngineCapacity, float i_EnergyPercentage) { return(new Motorcycle(i_LicenseType, i_EngineCapacity, i_EnergyStorage, i_ModelName, i_LicenseNumber, i_Wheels, i_EnergyPercentage)); }
public static Motorcycle CreateMotorcycle(Motorcycle.eLicenseType i_LicenseType, int i_EngineVolume, string i_ModelName, string i_LicensePlateNumber, Vehicle.eMaximumAirPressure i_MaximumAirPressureForVehicle, List <Wheel> i_WheelList, Engine i_VehicleEngine) { Motorcycle newMotorcycle = new Motorcycle(i_LicenseType, i_EngineVolume, i_ModelName, i_LicensePlateNumber, i_MaximumAirPressureForVehicle, i_WheelList, i_VehicleEngine); return(newMotorcycle); }
public static Vehicle CreateVehicle( ref string i_VehicleType, string i_EnergySource, Dictionary <string, string> i_VehicleProperties) { Vehicle newVehicle; string modelName = i_VehicleProperties["Model Name"]; string licensePlate = i_VehicleProperties["License plate"]; float energyPercentage = float.Parse(i_VehicleProperties["Energy Percentage (number 0-100)"]); energyPercentage /= 100; Wheel[] wheelsOfVehicle = getWheels(i_VehicleType, i_VehicleProperties); EnergySource energySource = getEnergySource(i_EnergySource, i_VehicleType, i_VehicleProperties); switch (i_VehicleType) { case "Car": Car.eCarColor CarColor = getCarColor(i_VehicleProperties[s_CarProperties[0]]); int numOfDoors = int.Parse(i_VehicleProperties[s_CarProperties[1]]); newVehicle = new Car( modelName, licensePlate, energyPercentage, wheelsOfVehicle, energySource, CarColor, numOfDoors); break; case "Motorcycle": Motorcycle.eLicenseType LicenseType = getMotorcycleLicesneType( i_VehicleProperties[s_MotorcycleProperties[0]]); int engineVolume = int.Parse(i_VehicleProperties[s_MotorcycleProperties[1]]); newVehicle = new Motorcycle( modelName, licensePlate, energyPercentage, wheelsOfVehicle, energySource, LicenseType, engineVolume); break; case "Truck": bool isCarriageDangerous = getIsTruckCarriageDangerous( i_VehicleProperties[s_TruckProperties[0]]); float carriageCapacity = float.Parse( i_VehicleProperties[s_TruckProperties[1]]); newVehicle = new Truck( modelName, licensePlate, energyPercentage, wheelsOfVehicle, energySource, isCarriageDangerous, carriageCapacity); break; default: throw new Exception("Vehicle type is not valid"); } return(newVehicle); }
private static void registerVehicle(string i_VehicleLicensePlate, Garage i_Garage) { string stringUserChoiceForVehicle; int intUserChoiceForVehicle = 0; bool isChoiceValid = !true; CreateVwhicleInGarage.eVehicleTypes typeOfVehicleToAdd; string vehicleOwnersName = getVehicleOwnersName(); string vehicleOwnersPhoneNumber = getVehicleOwnersPhoneNumber(); string vehicleModelName = getVehicleModelName(); Engine engineForVehicle; List <Wheel> wheelsForVehicle; Vehicle vehicleToAdd = null; VehicleInGarage newVehicleToAddToTheGarage; while (isChoiceValid == !true) { printVehicleMenu(); stringUserChoiceForVehicle = Console.ReadLine(); try { intUserChoiceForVehicle = convertUserChoiceToInt(stringUserChoiceForVehicle); isChoiceValid = checkChoiceValidity(intUserChoiceForVehicle, 1, k_NumberOfVehicleTypes); } catch (FormatException) { Console.WriteLine("Invalid input! bad format"); } } typeOfVehicleToAdd = (CreateVwhicleInGarage.eVehicleTypes)intUserChoiceForVehicle; switch (typeOfVehicleToAdd) { case CreateVwhicleInGarage.eVehicleTypes.Motorcycle: engineForVehicle = getEngineForUser(CreateVwhicleInGarage.eVehicleTypes.Motorcycle); wheelsForVehicle = getWheelsFromUser(Vehicle.eNuberOfWheelsForVehicle.TwoWheels, Vehicle.eMaximumAirPressure.MotorcycleAirPressure); Motorcycle.eLicenseType licenseType = getLicenseTypeFromUser(); int engineVolume = getEngineVolumeFromUser(); vehicleToAdd = CreateVwhicleInGarage.CreateMotorcycle(licenseType, engineVolume, vehicleModelName, i_VehicleLicensePlate, Vehicle.eMaximumAirPressure.MotorcycleAirPressure, wheelsForVehicle, engineForVehicle); break; case CreateVwhicleInGarage.eVehicleTypes.Car: engineForVehicle = getEngineForUser(CreateVwhicleInGarage.eVehicleTypes.Car); wheelsForVehicle = getWheelsFromUser(Vehicle.eNuberOfWheelsForVehicle.FourWheels, Vehicle.eMaximumAirPressure.CarAirPressure); Car.eNumbersOfDoors numberOfDoors = getNumberOfDoorsInCar(); Car.eColor carColor = getCarColor(); vehicleToAdd = CreateVwhicleInGarage.CreateCar(carColor, numberOfDoors, vehicleModelName, i_VehicleLicensePlate, Vehicle.eMaximumAirPressure.CarAirPressure, wheelsForVehicle, engineForVehicle); break; case CreateVwhicleInGarage.eVehicleTypes.Truck: engineForVehicle = getEngineForUser(CreateVwhicleInGarage.eVehicleTypes.Truck); wheelsForVehicle = getWheelsFromUser(Vehicle.eNuberOfWheelsForVehicle.TwelveWheels, Vehicle.eMaximumAirPressure.TruckAirPressure); bool isTrunkCooled = askUserIfTruckTrunkCooled(); float trunkVolume = getTruckTrunkVolumeFromUser(); vehicleToAdd = CreateVwhicleInGarage.CreateTruck(isTrunkCooled, trunkVolume, vehicleModelName, i_VehicleLicensePlate, Vehicle.eMaximumAirPressure.TruckAirPressure, wheelsForVehicle, engineForVehicle); break; } newVehicleToAddToTheGarage = CreateVwhicleInGarage.RegisterVehicleIntoGarage(vehicleOwnersName, vehicleOwnersPhoneNumber, vehicleToAdd); i_Garage.AddVehicleToTheGarageList(newVehicleToAddToTheGarage); Console.WriteLine("Vehicle added successfully"); }