private Vehicle getChosenVehicle(int i_ChosenSupportedVehicle, string i_LicenseNum) { Vehicle vehicleToCreate = null; switch (i_ChosenSupportedVehicle) { case 1: vehicleToCreate = VehiclesCreator.CreateFuelBasedMotorCycle(i_LicenseNum); break; case 2: vehicleToCreate = VehiclesCreator.CreateElectricMotorCycle(i_LicenseNum); break; case 3: vehicleToCreate = VehiclesCreator.CreateFuelBasedCar(i_LicenseNum); break; case 4: vehicleToCreate = VehiclesCreator.CreateElectricCar(i_LicenseNum); break; case 5: vehicleToCreate = VehiclesCreator.CreateFuelBasedTruck(i_LicenseNum); break; } return(vehicleToCreate); }
private static void insertNewVehicle(Garage i_Garage) { Console.WriteLine("Please enter license number:"); string licenseNum = checkIfnotEmpty(Console.ReadLine()); bool alreadyInTheGarage = i_Garage.CheckIfInGarage(licenseNum); if (!alreadyInTheGarage) { Console.WriteLine("Please enter owner's name:"); string ownerName = checkIfnotEmpty(Console.ReadLine()); Console.WriteLine("Please enter owner's number:"); string ownerNumber = checkIfnotEmpty(Console.ReadLine()); Console.WriteLine("Please enter model's name:"); string modelName = checkIfnotEmpty(Console.ReadLine()); VehiclesCreator.VehicleType selectedType = vehicleSelection(i_Garage); Dictionary <string, string> vehicleDictionary = new Dictionary <string, string>(); List <string> vehicleProperties = i_Garage.GetProperties(selectedType); foreach (string property in vehicleProperties) { string toPrint = string.Format("Please enter {0}:", property); Console.WriteLine(toPrint); vehicleDictionary.Add(property, Console.ReadLine()); } vehicleDictionary.Add("Owner name", ownerName); vehicleDictionary.Add("Owner phone", ownerNumber); vehicleDictionary.Add("License number", licenseNum); vehicleDictionary.Add("Model name", modelName); try { Vehicle newVehicle = VehiclesCreator.SelectConstructor(selectedType, vehicleDictionary); i_Garage.AddVehicle(newVehicle, licenseNum); } catch (ArgumentException e) { Console.WriteLine(e.Message); } catch (FormatException e) { Console.WriteLine(e.Message); } catch (ValueOutOfRangeException e) { Console.WriteLine(e.Message); } } else { Console.WriteLine("Your vehicle is already in the garage."); } }
private int getSupportedVehicle() { string input = Console.ReadLine(); while (!VehiclesCreator.IsSupportedVehicleNumber(input)) { Console.WriteLine("Please enter valid number"); input = Console.ReadLine(); } return(int.Parse(input)); }
public GarageManager() { garage = new Garage(); vehiclesCreator = new VehiclesCreator(); }