private void createAndAddNewVehicle() { string licensePlateNumber; bool isVehicleExist; Vehicle newVehicle; licensePlateNumber = getLicenseInput(); isVehicleExist = m_GarageLogic.DoesVehicleExist(licensePlateNumber); if (!isVehicleExist) { newVehicle = creatNewVehicle(); fillVehicleDetails(newVehicle, licensePlateNumber); m_GarageLogic.AddVehicleToGarage(newVehicle); Console.Clear(); Console.WriteLine("Vehicle entered to garage"); Thread.Sleep(k_afterExeptionTime); } else { m_GarageLogic.ChangeStateOfVehicle(licensePlateNumber, StateOfVehicle.CurrentlyFixed); Console.WriteLine("The vehicle exist in the garage. The status is: CurrentlyFixed"); Thread.Sleep(k_afterExeptionTime); } }
internal void AddVehicleToGarage() { Vehicle vehicle; VehicleCreater.eVehicleTypes vehicleType; while (true) { try { vehicleType = (VehicleCreater.eVehicleTypes)InputValidation.EnumChoiseToInt(typeof(VehicleCreater.eVehicleTypes), UserConsole.ChooseString("vehicle type")); vehicle = VehicleCreater.InitVehicle(vehicleType); vehicle.LicenseNumber = InputValidation.GetString("\nEnter License number: "); vehicle.ModelName = InputValidation.GetString("\nEnter model Name: "); r_Garage.AddVehicleToGarage(vehicle); break; } catch (Exception ex) { UserConsole.ExceptionOutput(ex); } } vehicle.VehicleInfo = setVehicleInfo(); setEnergy(vehicle); UserConsole.SleepAndClear(); setWheelInfo(vehicle); UserConsole.Print("\n"); setExtraDeatails(vehicle); UserConsole.Print("\nVehicle was added successfully!"); endAction(); }
private void addVehicleToGarageMenu() { Vehicle vehicleToAddGarage, vehicleExists; CustomerCard customerInfo; Console.WriteLine("Please enter the license plate number"); string licensePlateNumber = returnStringIfNotEmpty(); if (!m_Garage.IsVehicleExistsInGarage(licensePlateNumber, out vehicleExists)) { vehicleToAddGarage = getVehicle(licensePlateNumber); customerInfo = getCustomerInfo(); m_Garage.AddVehicleToGarage(vehicleToAddGarage, customerInfo); Console.Clear(); Console.WriteLine(string.Format("The vehicle with license plate number of {0} was added to the garage!", vehicleToAddGarage.LicencsePlateNumber)); Thread.Sleep(k_DelayTime); } else { m_Garage.ChangeStatusOfCar(vehicleExists, eRepairStatus.InRepair); Console.Clear(); Console.WriteLine(string.Format("The vehicle with license plate number of {0} is already exists in the garage system, status was changed to inRepair", vehicleExists.LicencsePlateNumber)); Thread.Sleep(k_DelayTime); } }
private void addVehicleToGarage(Vehicle i_VehicleToAdd, Garage i_Garage) { askFromUserVehiclesCurrentInformation(); i_VehicleToAdd.OwnerOfTheVehicle = Console.ReadLine(); i_VehicleToAdd.NumberPhoneOfOwner = getNumberValidInput(); i_VehicleToAdd.CurrentWheelsPressure(float.Parse(Console.ReadLine())); i_VehicleToAdd.EnergySource.CurrentAmountOfForce = float.Parse(Console.ReadLine()); i_Garage.AddVehicleToGarage(i_VehicleToAdd); }
private void AddVehicle() { string[] EnumVehicleNameStrings = Enum.GetNames(typeof(eVehicleType)); for (int i = 0; i < EnumVehicleNameStrings.Length; i++) { EnumVehicleNameStrings[i] = FixEnumStringLayout(EnumVehicleNameStrings[i]); } try { GarageUIMenuMesseges.PrintVehicleTypeToAddMenu(EnumVehicleNameStrings); int selection = GetValidInput(1, 5); eVehicleType vehicleType = (eVehicleType)selection; Vehicle vehicleToAdd = VehicleFactory.ConstructVehicle(vehicleType); GetBaseValuesForVehicle(vehicleToAdd); List <string> inputReqMsgs = vehicleToAdd.GetInputRequestMesseges(); List <string> userInputList = new List <string>(); foreach (string inputReqMsg in inputReqMsgs) { System.Console.WriteLine(inputReqMsg); string inputDataStr = System.Console.ReadLine(); userInputList.Add(inputDataStr); } vehicleToAdd.ExtractSpecificVehicleDataValues(userInputList); bool vehicleAlreadyInGarage = m_Garage.AddVehicleToGarage(vehicleToAdd.VehicleID, vehicleToAdd); if (vehicleAlreadyInGarage) { System.Console.WriteLine("Error, vehicle already exists in garage!"); GarageUIMenuMesseges.ClearAndPrintAnyKey(); } else { GarageUIMenuMesseges.PrintOperationDone(); } } catch (ValueOutOfRangeException ex) { System.Console.WriteLine(ex.ToString()); GarageUIMenuMesseges.ClearAndPrintAnyKey(); } catch (FormatException ex) { System.Console.WriteLine(ex.ToString()); GarageUIMenuMesseges.ClearAndPrintAnyKey(); } catch (Exception ex) { System.Console.WriteLine(ex.ToString()); GarageUIMenuMesseges.ClearAndPrintAnyKey(); } }
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 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."); } }
private static void addVehicleToGarage() { bool vehicleIsAlreadyInGarage; Vehicle vehicleToAdd; vehicleToAdd = getVehicleFromUser(); vehicleIsAlreadyInGarage = s_Garage.AddVehicleToGarage(vehicleToAdd); if (vehicleIsAlreadyInGarage) { Console.WriteLine(string.Format("A vehicle with that plate number already exists, choose another option")); } else { Console.WriteLine("Vehicle was added succesfully"); } }
private void addVehicleToGarage() { showAvailableVehicles(); VehiclesFactory.eVehicleType vehicleType = selectVehicleType(); Client client = getClientInformation(); ArgumentConsumersContainer vehicleArgumentsContainer = VehiclesFactory.GetVehicleArguments(vehicleType); fillVehicleArguments(vehicleArgumentsContainer, vehicleType); Vehicle vehicleToAdd = VehiclesFactory.GetVehicle(vehicleType, vehicleArgumentsContainer); ClientVehicle clientVehicle = new ClientVehicle(client, vehicleToAdd, ClientVehicle.eClientVehicleStatus.InRepair); bool didCarEnterTheGarage = r_Garage.AddVehicleToGarage(clientVehicle); printMessageToConsole( didCarEnterTheGarage == true ? eMessageToPrint.CarHasEnteredTheGarage : eMessageToPrint.CarIsAlreadyInTheGarage); }
private void insertVehicleToGarage() { Vehicle vehicleToAdd = null; Customer customerToAdd = null; string vehicleToAddLicenseNumber = getNotEmptyStringFromUser(k_VehicleLicenseNumber); bool isVehicleAlreadyInTheGarage = r_Garage.IsVehicleInTheGarage(vehicleToAddLicenseNumber); if (isVehicleAlreadyInTheGarage) { r_Garage.ChangeVehicleStatus(vehicleToAddLicenseNumber, Customer.eVehicleStatusInTheGarage.InRepair); Console.Write("The vehicle with license number {0} is already in the garage. his status changed to in repair.{1}", vehicleToAddLicenseNumber, Environment.NewLine); } else { vehicleToAdd = getVehicleFromUser(vehicleToAddLicenseNumber); customerToAdd = getCustomerFromUser(); r_Garage.AddVehicleToGarage(vehicleToAdd, customerToAdd); Console.WriteLine("{0}Successfully insert vehicle To Garage", Environment.NewLine); } }
////Handle Add Veichle to garage ////Take all Vehicles types in garage from VehicleFactory class ////Building an object-type collection that will contain all the parameter-types for building the vehicle, according to user's choice ////Building a wheel-type collection according to vehicle-type user select private void handleAddVehicle(Garage garage) { Dictionary <eVehicleTypes, Type> vehicles = VehicleFactory.Vehicles; Dictionary <eVehicleTypes, int> wheelsNumber = VehicleFactory.WheelsNumberPerVehicle; Type[] parametersTypesFromConstructor; List <string> parametersDescription = new List <string>(); string ownerName = string.Empty; string ownerPhone = string.Empty; Wheel[] wheelsArray; List <object> paramsToBuildVehicle = new List <object>(); eVehicleTypes vehicleChoise; getOwnerNameAndPhone(out ownerName, out ownerPhone); vehicleChoise = getVehicleTypeFromUser(vehicles.Keys); parametersTypesFromConstructor = ConstructorReflection.GetConstructorParametersTypes(vehicles[vehicleChoise], parametersDescription); paramsToBuildVehicle = getParametersFromUserByVehicleType(parametersTypesFromConstructor, parametersDescription.ToArray()); wheelsArray = getWheelsArray(wheelsNumber[vehicleChoise], vehicles[vehicleChoise]); garage.AddVehicleToGarage(ownerName, ownerPhone, vehicleChoise, paramsToBuildVehicle, wheelsArray); }
public static void AddNewVehicleToGarage(Garage i_Garage) { string ownerNameInput = string.Empty; string ownerPhoneNumberInput = string.Empty; //VehicleInputData o_VehicleData; //GetOwnerNameFromUser(out ownerNameInput); //GetOwnerPhoneNumberFromUser(out ownerPhoneNumberInput); //o_VehicleData = GetVehicleDataFromUser(); ////// Example Car ////// ownerNameInput = "Ilan Kushnir"; ownerPhoneNumberInput = "0505877898"; VehicleInputData o_VehicleData = new VehicleInputData(); o_VehicleData.m_Color = Car.eCarColor.Red; o_VehicleData.m_CurrentAirPressure = 30; o_VehicleData.m_CurrentFuelCapacity = 40; o_VehicleData.m_Doors = Car.eNumOfDoors.Three; o_VehicleData.m_FuelType = Fuel.eFuelType.Octan95; o_VehicleData.m_LicenseNumber = "1234567"; o_VehicleData.m_MaxAirPressure = 32; o_VehicleData.m_MaxFuelCapacity = 50; o_VehicleData.m_ModelName = "The Off-Mobil"; o_VehicleData.m_VehicleType = eVehicleType.Car; o_VehicleData.m_WheelsManufacturer = "Michelin abu hasuna"; ///////////////////////// try { i_Garage.AddVehicleToGarage(ownerNameInput, ownerPhoneNumberInput, o_VehicleData); Console.WriteLine("The car added successfuly to the garage" + Environment.NewLine); } catch (VehicleAllreadyInGarageException ex) { Console.WriteLine("Vehicle with license number " + ex.LicenseNumber + " is allready taken care in the garage. Status changed to InService"); } }
private void insertNewVehicleToGarage(string i_LicenseNumber, Vehicle i_NewVehicle) { string ownerName, ownerPhoneNumber; bool isValidInput; receiveVehicleOwnerInformation(out ownerName, out ownerPhoneNumber); List <string> userDialogueStringsList = i_NewVehicle.GetUserDialogueStrings(); List <string> userDialogueInputsList = new List <string>(); for (int i = 0; i < userDialogueStringsList.Count; ++i) { isValidInput = false; Console.Write(userDialogueStringsList[i]); do { try { string userInput = Console.ReadLine(); if (i_NewVehicle.CheckLatestUserInput(userInput, i)) { isValidInput = true; userDialogueInputsList.Add(userInput); } } catch (FormatException formatException) { Console.Write("Invalid input, please try again: "); } catch (ValueOutOfRangeException valueOutOfRangeException) { Console.Write("You must enter a number between {0} and {1}: ", valueOutOfRangeException.MinValue, valueOutOfRangeException.MaxValue); } }while(!isValidInput); } i_NewVehicle.UpdateProperties(userDialogueInputsList); r_Garage.AddVehicleToGarage(i_LicenseNumber, ownerName, ownerPhoneNumber, i_NewVehicle); }
public static void AddVehicle(Garage i_Garage) { Console.WriteLine("Please choose the type of vehicle you would like to enter the garage:"); int numOption = GetTypeOption(); string licenseNum = GetLicenseNumStr(); if (i_Garage.TryToFindClient(licenseNum, out ClientCard newClient) == true) { Console.WriteLine("The Vehicle is already in the garage"); i_Garage.ChangeVehicleStatus(newClient, Garage.eVehicleStat.InRepair); } else { string ownerName; string ownerPhoneNum; Vehicle vehicleToAdd = Instance.GenerateInstance((Instance.eVehicleType)numOption - 1, licenseNum); for (int i = 0; i < vehicleToAdd.MemberInfoStrings.Count; i++) { bool fieldIsValid = false; while (fieldIsValid == false) { Console.WriteLine("Please enter {0}", vehicleToAdd.MemberInfoStrings[i]); string inputStr = Console.ReadLine(); fieldIsValid = vehicleToAdd.TryAssignMember(i, inputStr, out string errorMessage); if (fieldIsValid == false) { Console.WriteLine(errorMessage); } } } ownerName = GetNameFromUser(); ownerPhoneNum = GetPhoneNumberFromUser(); i_Garage.AddVehicleToGarage(new ClientCard(vehicleToAdd, ownerName, ownerPhoneNum)); Console.WriteLine("The Vehicle successfully added to the garage "); } }
/** * This method gets the vehicles details from user * Catches ArgumentException */ public Vehicle GetVehicleDetailsFromUser() { Vehicle vehicleToAdd = null; try { vehicleToAdd = VehicleBuilder.MakeVehicle(getVehicleType()); vehicleToAdd.LicenseNumber = getLicenseNumber(); r_Garage.AddVehicleToGarage(vehicleToAdd); vehicleToAdd = fillDetails(vehicleToAdd); ConsoleUtils.ClearConsoleAndWrite("Vehicle added successfully!"); Console.WriteLine("Press any key to continue"); Console.ReadLine(); } catch (ArgumentException ae) { ConsoleUtils.ClearConsoleAndWrite(ae.Message); Console.WriteLine("Press any key to continue"); Console.ReadLine(); } return(vehicleToAdd); }
private void addCar(string i_LicensePlate, string i_OwnerName, string i_OwnerPhoneNumber) { string userChoice; string modelName; bool correctChoice; Car.eCarDoors numOfDoors; Car.eCarColor carColor; List <string> tireManufacturer; List <float> airPressure; Vehicle car = null; Console.WriteLine("Please enter the model name of the car:"); modelName = Console.ReadLine(); Console.WriteLine("Please enter the names of all the tires manufacturers:"); tireManufacturer = createTireManufacturerList(Car.NumOfTires); airPressure = checkAndCreateAirPressureList(Car.NumOfTires, Car.MaxTirePressure); do { Console.WriteLine("Please choose how many doors the car has:"); printEnumNames(typeof(Car.eCarDoors)); userChoice = Console.ReadLine(); correctChoice = Enum.IsDefined(typeof(Car.eCarDoors), userChoice); if (correctChoice == false) { Console.WriteLine("Invalid input."); } }while (correctChoice == false); Enum.TryParse <Car.eCarDoors>(userChoice, out numOfDoors); correctChoice = false; do { Console.WriteLine("Please choose the color of the car:"); printEnumNames(typeof(Car.eCarColor)); userChoice = Console.ReadLine(); correctChoice = Enum.IsDefined(typeof(Car.eCarColor), userChoice); if (correctChoice == false) { Console.WriteLine("Invalid input."); } }while (correctChoice == false); Enum.TryParse <Car.eCarColor>(userChoice, out carColor); userChoice = checkAndChoosePowersource(); if (userChoice == "Battery") { car = VehicleFactory.CreateVehicle(i_LicensePlate, VehicleFactory.eVehicleType.ElectricCar, modelName, airPressure, tireManufacturer, carColor, numOfDoors); } else if (userChoice == "Fuel") { car = VehicleFactory.CreateVehicle(i_LicensePlate, VehicleFactory.eVehicleType.FueledCar, modelName, airPressure, tireManufacturer, carColor, numOfDoors); } VehicleInGarage carInGarage = new VehicleInGarage(i_OwnerName, i_OwnerPhoneNumber, car); m_Garage.AddVehicleToGarage(carInGarage); }