private void addNewVehicle() { string licenseNumber = getLicenseNumber(); if (Garage.AllVehicles.ContainsKey(licenseNumber)) { Garage.UpdateVehicleRepairStatus(licenseNumber, Garage.eRepairStatus.InRepair); Console.WriteLine("Welcome back, your vehicle is in repair!"); } else { Console.WriteLine("\nPlease enter your name:"); string ownerName = Console.ReadLine(); bool isValidName = !string.IsNullOrEmpty(ownerName); while (!isValidName) { Console.WriteLine("The name must contain at least one letter, please try again"); ownerName = Console.ReadLine(); isValidName = !string.IsNullOrEmpty(ownerName); } int ownerPhoneNumber = getPhoneNumber(); VehicleCreator.eSupportedVehicles vehicleType = getVehicleType(); Vehicle newVehicle = createNewVehicle(vehicleType, licenseNumber); Garage.CostumerVehicle newCostumerVehicle = new Garage.CostumerVehicle(ownerName, ownerPhoneNumber, newVehicle); r_Garage.AllVehicles.Add(licenseNumber, newCostumerVehicle); Console.WriteLine("Thank you for joining our family!"); System.Threading.Thread.Sleep(1500); Console.Clear(); } }
private static VehicleCreator.eSupportedVehicles getVehicleType() { printListOfEnum("\nPlease choose a vehicle", typeof(VehicleCreator.eSupportedVehicles)); string vehicleTypeInput = Console.ReadLine(); while (!checkEnumValidation(typeof(VehicleCreator.eSupportedVehicles), vehicleTypeInput)) { Console.WriteLine("Invalid vehicle type input, please try again"); vehicleTypeInput = Console.ReadLine(); } VehicleCreator.eSupportedVehicles vehicleType = (VehicleCreator.eSupportedVehicles)Enum.Parse( typeof(VehicleCreator.eSupportedVehicles), vehicleTypeInput); return(vehicleType); }
private Vehicle createNewVehicle(VehicleCreator.eSupportedVehicles i_VehicleType, string i_LicenseNumber) { Console.WriteLine("\nPlease enter your vehicle's model name:"); string modelName = Console.ReadLine(); while (string.IsNullOrEmpty(modelName)) { Console.WriteLine("The model name must contain at least one letter, please try again"); modelName = Console.ReadLine(); } float energyLeft = getEnergyLeftPercentage(); Vehicle newVehicle = VehicleCreator.CreateVehicle(i_LicenseNumber, modelName, energyLeft, i_VehicleType); List <string> answers = getAdditionalSpecificDetails(newVehicle); newVehicle.UpdateAdditionalInfo(answers); return(newVehicle); }