private void updateVehicleProperties(int i_TypeOfVehicleFromUser, Vehicle i_NewVehicleToGarage, string i_ManufactureName, float i_WheelsCurrentAirPressure) { int firstIndex, secondIndex = 0; getTwoIndexesOfCommands(i_TypeOfVehicleFromUser, out firstIndex, out secondIndex); while (true) { try { Console.WriteLine(m_InputStringsArray[firstIndex]); string firstPropertie = ValidationOfData.GetStringFromUser(); Console.WriteLine(m_InputStringsArray[secondIndex]); string secondPropertie = ValidationOfData.GetStringFromUser(); i_NewVehicleToGarage.UpdateSpecificPropeties(firstPropertie, secondPropertie); updateEngineProperties(i_NewVehicleToGarage); i_NewVehicleToGarage.UpdateWheels(i_ManufactureName, i_WheelsCurrentAirPressure); return; } catch (FormatException ex) { Console.WriteLine(@"Input invalid due to '{0}'.please enter again:", ex.Message); } catch (ValueOutOfRangeException ex) { Console.WriteLine(ex.Message); } catch (ArgumentException ex) { Console.WriteLine(@"Wrong input due to {0},please enter again:", ex.Message); } } }
private string getLicenseNumberFromUser() { Console.WriteLine("Please enter the Vehicles license number:"); string licenseNumberFromUser = ValidationOfData.GetStringFromUser(); return(licenseNumberFromUser); }
private void createNewVehicle() { int EngineType = 1; bool isVehicleAlreadtInGarage = false; Console.WriteLine("Please enter the license number:"); string licenseNumber = ValidationOfData.GetStringFromUser(); isVehicleAlreadtInGarage = m_HadarAndKochGarage.SearchVehicleInGarage(licenseNumber); if (!isVehicleAlreadtInGarage) { Console.WriteLine("Please enter the vehicle model:"); string vehicleModel = ValidationOfData.GetStringFromUser(); string vehicleMenuToPrint = string.Format( @"Please enter the type of vehicle: 1.Car 2.Motorcycle 3.Truck"); Console.WriteLine(vehicleMenuToPrint); int TypeOfVehicleFromUser = ValidationOfData.GetIntFromUserWithinRange(3, 1); if (TypeOfVehicleFromUser != 3) { string enginMenuToPrint = string.Format( @"Please enter the type of Engine(press the number): 1.Fuel 2.Electric"); Console.WriteLine(enginMenuToPrint); EngineType = ValidationOfData.GetIntFromUserWithinRange(2, 1); } Vehicle newVehicleToGarage = Garage.CreateTheSpecificVehicle(vehicleModel, licenseNumber, TypeOfVehicleFromUser, EngineType); Console.WriteLine("Please enter the wheels manufacture name:"); string manufactureName = ValidationOfData.GetStringFromUser(); Console.WriteLine("Please enter the wheels current air pressure:"); float wheelsCurrentAirPressure = ValidationOfData.GetTheAirPressure(newVehicleToGarage); updateVehicleProperties(TypeOfVehicleFromUser, newVehicleToGarage, manufactureName, wheelsCurrentAirPressure); Console.WriteLine("Please enter your phone number:"); long phoneNumber = ValidationOfData.GetLongIntFromUser(); Console.WriteLine("Please enter your name:"); string ownerName = ValidationOfData.GetStringFromUser(); m_HadarAndKochGarage.AddVehicleToGarage(newVehicleToGarage, ownerName, phoneNumber, eVehicleStatusInGarage.InProgress); } else { Console.WriteLine("Vehicle with the same license number is already in our garage.Please try again."); } }