/* 1) Insert new Vehicle into Garage */ private void insertNewVehicleIntoGarage() { System.Console.WriteLine(createMenuStringFromEnum(typeof(Factory.eVehicleType), "Insert New Vehicle")); int vehicleTypeNumber = promptUserForMenuSelection(Enum.GetNames(typeof(Factory.eVehicleType)).Length); Factory.eVehicleType vehicleToAdd = (Factory.eVehicleType)vehicleTypeNumber - 1; string licenseNumber; this.promptUserForLicenseNumber(out licenseNumber); if (this.m_Garage.IsInGarage(licenseNumber)) { System.Console.WriteLine("Veicle currently in garage. Status changed to: In Repair."); this.m_Garage.StatusInRepairedUpdate(licenseNumber); System.Console.WriteLine(Environment.NewLine); } else { System.Console.WriteLine("Please enter Owner name:"); string ownerName = System.Console.ReadLine(); string phoneNumMessage = string.Format("Please enter Owners phone number ({0}-{1} digits):", k_MinPhoneNumLength, k_MaxPhoneNumLength); string validPhoneNumMessage = string.Format("Please enter a valid phone number ({0} -{1} digits:", k_MinPhoneNumLength, k_MaxPhoneNumLength); System.Console.WriteLine(phoneNumMessage); string ownerPhoneNumber = System.Console.ReadLine(); while (!Vehicle.isLegalPhoneNumber(ownerPhoneNumber)) { System.Console.WriteLine(validPhoneNumMessage); ownerPhoneNumber = System.Console.ReadLine(); } System.Console.WriteLine("Please enter Vehicles Model Name:"); string vehicleModelName = System.Console.ReadLine(); this.m_Garage.InsertNewVehicle(vehicleToAdd, licenseNumber, ownerName, ownerPhoneNumber, vehicleModelName); System.Console.WriteLine(createMenuStringFromEnum(typeof(eTireAirPressureStatus), "Do all tires have the same air pressure")); int tireStatusNumber = promptUserForMenuSelection(Enum.GetNames(typeof(Factory.eVehicleType)).Length); Vehicle createdVehicle; m_Garage.GetVehicle(licenseNumber, out createdVehicle); List <float> tirePressures = new List <float>(); if (tireStatusNumber == 1) { float singleTireAirPressure = this.getTirePressureFromUser(createdVehicle); for (int i = 0; i < createdVehicle.NumberOfWheels; i++) { tirePressures.Add(singleTireAirPressure); } } else { for (int i = 0; i < createdVehicle.NumberOfWheels; i++) { tirePressures.Add(getTirePressureFromUser(createdVehicle)); } } System.Console.WriteLine("Please enter Tires Manufacturer Name:"); string tiresManufacturerName = System.Console.ReadLine(); Factory.CreateWheels(createdVehicle, tiresManufacturerName, tirePressures); //TODO int userChoice; if (createdVehicle is Car) { System.Console.WriteLine(createMenuStringFromEnum(typeof(Car.eColor), "Enter the car's color:")); userChoice = promptUserForMenuSelection(Enum.GetNames(typeof(Car.eColor)).Length); ((Car)createdVehicle).Color = (Car.eColor)userChoice - 1; System.Console.WriteLine(createMenuStringFromEnum(typeof(Car.eNumOfDoors), "Enter the car's number of doors:")); userChoice = promptUserForMenuSelection(Enum.GetNames(typeof(Car.eNumOfDoors)).Length); ((Car)createdVehicle).NumberOfDoors = (Car.eNumOfDoors)userChoice - 1; /*Factory.CreateCarFeatures((Car)createdVehicle, (Car.eNumOfDoors)userChoice, (Car.eColor)userChoice); //TODO * * ((Car)createdVehicle).SetCarDoorsAndColor((Car.eColor)userChoice , (Car.eNumOfDoors)userChoice);*/ } else if (createdVehicle is Motorcycle) { System.Console.WriteLine(createMenuStringFromEnum(typeof(Motorcycle.eLicenseType), "Enter the motorcycles's license type:")); userChoice = promptUserForMenuSelection(Enum.GetNames(typeof(Motorcycle.eLicenseType)).Length); ((Motorcycle)createdVehicle).LicenceType = (Motorcycle.eLicenseType)userChoice - 1; System.Console.WriteLine("Please enter engine volume:"); userChoice = (int)getFloatFromUser(0, int.MaxValue); ((Motorcycle)createdVehicle).EngineVolume = userChoice; } else if (createdVehicle is Truck) { System.Console.WriteLine(createMenuStringFromEnum(typeof(eIsCarryingHazardousMaterials), "Is the truck carrying hazardous materials?:")); userChoice = promptUserForMenuSelection(Enum.GetNames(typeof(eIsCarryingHazardousMaterials)).Length); if (userChoice == 1) { ((Truck)createdVehicle).HasHazardousMaterials = true; } else { ((Truck)createdVehicle).HasHazardousMaterials = false; } System.Console.WriteLine("Please enter maximum allowed weight:"); float maxWeightAllowed = getFloatFromUser(0, int.MaxValue); ((Truck)createdVehicle).MaxWeightAllowed = maxWeightAllowed; } if (createdVehicle.Engine is FuelBasedEngine) { System.Console.WriteLine("Please enter current amount of fuel:"); float currentAmountOfFuel = getFloatFromUser(0, (float)((FuelBasedEngine)createdVehicle.Engine).MaxAmountOfFuel); ((FuelBasedEngine)createdVehicle.Engine).CurrentAmountOfFuel = currentAmountOfFuel; } else if (createdVehicle.Engine is ElectricBasedEngine) { System.Console.WriteLine("Please enter remaining time of engine operation in hours:"); float currentBatteryEnergy = getFloatFromUser(0, (float)((ElectricBasedEngine)createdVehicle.Engine).MaxBatteryLife); ((ElectricBasedEngine)createdVehicle.Engine).RemainingTimeOnBattery = currentBatteryEnergy; } } returnToMenuOrQuit(); }