/// <summary> /// Method for the 5'th case of the main menu user choice. /// Case 5 takes care both for battery charging and tank feuling. /// </summary> internal void MethodForMainUserChoiceCase5() { string licenseNumber = string.Empty; float fuelAmountToAdd = float.MinValue; float currentEnergyAmount = float.MinValue; float maximumEnergyAmount = float.MinValue; Engine.e_EnergyType energyType = Engine.e_EnergyType.Soler; Vehicle currentVehicle; licenseNumber = ConsoleUI.LicenseNumberInput(); if (m_garage.OwnerVehicleDictionary.ContainsKey(licenseNumber) == true) { energyType = ConsoleUI.EnergyTypeToAppointInput(); currentVehicle = m_garage.GetVehicleByLicenseNumber(licenseNumber); if (currentVehicle.EngineType.EnergyType == energyType) { currentEnergyAmount = currentVehicle.EngineType.CurrentEnergyResource; maximumEnergyAmount = currentVehicle.EngineType.MaximumEnergyResource; fuelAmountToAdd = ConsoleUI.EnergyAmountToAppointInput(currentEnergyAmount, maximumEnergyAmount); m_garage.ReEnergyVehicleByGivenAmount(licenseNumber, energyType, fuelAmountToAdd); } else { throw new ArgumentException("The Energy Type does not fit the engine\n"); } } else { throw new Exception("The specific vehicle is not in the dictionary\n"); } }
internal static Engine.e_EnergyType EnergyTypeToAppointInput() { string energyStringType = string.Empty; int energyIntType = int.MinValue; Engine.e_EnergyType energyType = Engine.e_EnergyType.Soler; Console.WriteLine( @"Energy Type To Appoint: 1) Soler 2) Octan95 3) Octan96 4) Octan98 5) Battery"); energyIntType = UserChoiceForRangeCheck(GlobalConstants.lowerRangeOfVehicleChoice, GlobalConstants.upperRangeOfVehicleChoice); energyType = (Engine.e_EnergyType)Enum.ToObject(typeof(Engine.e_EnergyType), energyIntType); return(energyType); }
/// <summary> /// /// </summary> /// <param name="i_licenseNumber">the change is made by the given license number</param> /// <param name="i_energyType">the chosen energy type to appoint- input will be check for right type</param> /// <param name="i_amountToAppoint">the amount to appoint- input will be checked for logical amount to put in tank/battery </param> public void ReEnergyVehicleByGivenAmount(string i_licenseNumber, Engine.e_EnergyType i_energyType, float i_amountToAppoint) { if (CheckIfDictionaryNotEmpty() == true) { if (m_ownerVehicleDictionary.TryGetValue(i_licenseNumber, out m_ownerDetailsAndVehicle) == true) { m_ownerDetailsAndVehicle.OwnerVehicle.EngineType.EnergyAdder(i_amountToAppoint, i_energyType); } else { throw new FormatException(); } } else { throw new Exception("Vehicle Does not exsist in this garage\n"); } }