private void updateEngineProperties(Vehicle i_NewVehicleToGarage) { i_NewVehicleToGarage.UpdateEngine(); Console.WriteLine("Please enter the amount of energy left:"); float energyLeftInEngine = ValidationOfData.GetFloatFromUserWithinRange(i_NewVehicleToGarage.VehicleEngine.MaxAmountOfEnergy, 0); i_NewVehicleToGarage.SetEngineCurrentEnergy(energyLeftInEngine); }
private void fillEnergyOfVehicle(GarageVehicle i_SearchvihicleInGarage, bool i_IsRefuelNeed) { bool isSuccesfull = false; eFuelType fuelToRefill; eEngineType engineType; if (i_IsRefuelNeed) { Console.WriteLine("Please enter the fuel type you would like to fill in - Soler(1)/Octan95(2)/Octan96(3)/octan98(4) :"); fuelToRefill = ValidationOfData.GetFuelType(); engineType = eEngineType.Fuel; } else { fuelToRefill = eFuelType.Electricty; engineType = eEngineType.Electric; } Console.WriteLine("Please enter how many energy would you like to fill in:"); float amountOfEnergy = ValidationOfData.GetFloatFromUserWithinRange(i_SearchvihicleInGarage.VehicleInGarage.VehicleEngine.MaxAmountOfEnergy, 0); // to change it to within range try { isSuccesfull = i_SearchvihicleInGarage.FillFuelToMax(i_SearchvihicleInGarage.VehicleInGarage, engineType, fuelToRefill, amountOfEnergy); } catch (ValueOutOfRangeException ex) { Console.WriteLine(ex.Message); } catch (ArgumentException) { Console.WriteLine(@"The fuel type entered {0} doesn't match the fuel type required .", fuelToRefill); } catch (Exception) { Console.WriteLine(@"The energy type entered {0} doesn't match to the vehicle engine .", fuelToRefill); } if (isSuccesfull) { printTheResult(isSuccesfull); } }