public static Vehicle GetNewVehicle(ref Client i_Client, ref Garage i_Garage) { Vehicle newVehicle = null; generalVehicleDetailsLabel(); string vehicleLicenseNumber = GetVehicleLicenseNumber(); if (i_Garage.IsVehicleFoundInGarage(vehicleLicenseNumber)) { Folder folder; i_Garage.GarageDataBase.TryGetValue(vehicleLicenseNumber, out folder); folder.FolderSubject.Status = Vehicle.VehicleStatus.InRepair; Console.WriteLine("Vehicle License Number {0} Existing In Garage", vehicleLicenseNumber); Console.WriteLine("Vehicle Status Chaned to {0}", Vehicle.VehicleStatus.InRepair); } else { vehicleTypeLabel(); vehicleTypesInstructionMessage(); Vehicle.VehicleType vehicleType = getVehicleType(); string vehicleModel = getVehicleModel(); short vehicleWheelsNumber = getVehicleWheelsNumber(vehicleType); EnergySystem vehicleEnergySystem = EnergySystemUI.GetNewEnergySystem(vehicleType); List <Wheel> vehicleWheels = getVehicleWheels(vehicleWheelsNumber, vehicleType); if (vehicleType == Vehicle.VehicleType.Car) { newVehicle = CarUI.GetNewCar( ref i_Client, vehicleType, vehicleModel, vehicleLicenseNumber, ref vehicleEnergySystem, vehicleWheelsNumber, ref vehicleWheels); } else if (vehicleType == Vehicle.VehicleType.Motorcycle) { newVehicle = MotorcycleUI.GetNewMotorcycle( ref i_Client, vehicleType, vehicleModel, vehicleLicenseNumber, ref vehicleEnergySystem, vehicleWheelsNumber, ref vehicleWheels); } else if (vehicleType == Vehicle.VehicleType.Truck) { newVehicle = TruckUI.GetNewTruck( ref i_Client, vehicleType, vehicleModel, vehicleLicenseNumber, ref vehicleEnergySystem, vehicleWheelsNumber, ref vehicleWheels); } else { Console.WriteLine("Bad Selection"); } } return(newVehicle); }
internal static void Insert(ref Garage io_Garage) { System.Console.WriteLine("Please enter a license number:"); bool licenseNumInDict = false; string licenseNum = System.Console.ReadLine(); bool licenseNumValid = false; while (!licenseNumValid) { try { licenseNumInDict = io_Garage.PutNewVehicleInGarage(licenseNum); licenseNumValid = true; } catch (ArgumentException) { System.Console.WriteLine(@"License number invalid! Should be a number with 7 or 8 digits."); licenseNum = System.Console.ReadLine(); } } if (licenseNumInDict) { System.Console.WriteLine(@"This license number exists in the garage! Its status has changed to 'In Repair'. "); } else { System.Console.WriteLine("Please enter a desired type of vehicle:"); string vehicleTypeStr = System.Console.ReadLine(); Vehicle vehicle = null; while (vehicle == null) { try { vehicle = InputVehicleInitializer.ParseVehicleTypeFromUser(licenseNum, vehicleTypeStr); } catch { System.Console.WriteLine(@"Invalid vehicle type! Try 'Car' for example."); vehicleTypeStr = System.Console.ReadLine(); } } io_Garage.PutVehicleObjInDict(vehicle, licenseNum); askForOwnerName(licenseNum, ref io_Garage);//Set OwnerName to userInput askForOwnerPhoneNum(licenseNum, ref io_Garage); askForModelName(vehicle); askForEnergySource(vehicle); askForEnergyStats(vehicle); askForWheelsInfo(vehicle); if (vehicle is Motorcycle) { MotorcycleUI.askForLicenseType(vehicle as Motorcycle); MotorcycleUI.askForEngineVolume(vehicle as Motorcycle); } else if (vehicle is Car) { CarUI.askForColor(vehicle as Car); CarUI.askForNumOfDoors(vehicle as Car); } else if (vehicle is Truck) { TruckUI.askForDangerousMaterials(vehicle as Truck); TruckUI.askForVolumeOfCargo(vehicle as Truck); } } }