internal static void AddVehicleToTheGarage(eVehicleTypes i_VeicleToTheGarage) { bool isValid = false; string ownerName; string ownerPhoneNumber; GarageUI.GetVehicleOwnerDetails(out ownerName, out ownerPhoneNumber); Vehicle currentVehicleToAdd = VehicleCreation.CreateVehicle(i_VeicleToTheGarage); Dictionary <string, string> vehicleDetails = currentVehicleToAdd.CreateVehicleDetailsDict(); vehicleDetails = currentVehicleToAdd.EngineOfVehicle.AddEngineDetailsToDict(vehicleDetails); while (!isValid) { vehicleDetails = GarageUI.GetVehicleDetailsFromUser(vehicleDetails, currentVehicleToAdd); try { currentVehicleToAdd.AddVehicleInformation(vehicleDetails); currentVehicleToAdd.EngineOfVehicle.AddEngineInformation(vehicleDetails); isValid = true; } catch (Exception exception) { Console.WriteLine(exception.Message); } } VehicleInGarage newVehicleIntheGarage = new VehicleInGarage(currentVehicleToAdd, ownerName, ownerPhoneNumber); ListVehiclesInGarage.Add(currentVehicleToAdd.LicenseNumber, newVehicleIntheGarage); }
public static void Main() { UiManager uiManager = new UiManager(); ///////////////////////// test Wheel wheels1 = new Wheel("rwewr", 20, 40); Wheel wheels2 = new Wheel("rwewr", 20, 40); Wheel wheels3 = new Wheel("rwewr", 20, 40); Wheel wheels4 = new Wheel("rwewr", 20, 40); Wheel[] wheels = { wheels1, wheels2, wheels3, wheels4 }; Engine gas = new GasEngine(eGasType.Octan96, 30, 40); Engine electric = new ElectricEngine(50, 33); Motor motor = new Motor(eLicenseType.A, 50, "fsdf", "345", 432, wheels, gas, "rewr", 53, 432); Car car = new Car(eCarColors.BLACK, eCarDoors.FOUR, "rerete", "123", 20, wheels, gas, "erew", 40, 70); Car car2 = new Car(eCarColors.BLUE, eCarDoors.FIVE, "baa", "567", 30, wheels, electric, "rer", 42, 50); Truck truck = new Truck(true, 54, "rwe", "789", 25, wheels, gas, "gdds", 30, 50); VehicleInGarage vehicleInGarageMotor = new VehicleInGarage("Erez", "052482542", eVehicleRepairStatus.IN_PROGRESS, motor); VehicleInGarage vehicleInGarageCar = new VehicleInGarage("nofar", "05244324", eVehicleRepairStatus.IN_PROGRESS, car); VehicleInGarage vehicleInGarageCar2 = new VehicleInGarage("C#", "052442134222", eVehicleRepairStatus.IN_PROGRESS, car2); VehicleInGarage vehicleInGaragetruck = new VehicleInGarage("Netta barzilai", "0524461111", eVehicleRepairStatus.IN_PROGRESS, truck); uiManager.m_GarageManager.CurrentVehiclesInGarage.Add("345", vehicleInGarageMotor); uiManager.m_GarageManager.CurrentVehiclesInGarage.Add("123", vehicleInGarageCar); uiManager.m_GarageManager.CurrentVehiclesInGarage.Add("567", vehicleInGarageCar2); uiManager.m_GarageManager.CurrentVehiclesInGarage.Add("789", vehicleInGaragetruck); ////////////////////////// test uiManager.Run(); }
internal static void RefuelFuelVehicle(string i_VehicleLicenseNumber, FuelEngine.eFuelType i_TypeOfFuel, float i_AmountToFill) { VehicleInGarage currentVehicle = ListVehiclesInGarage[i_VehicleLicenseNumber]; Vehicle vehicleToAddEnergy = currentVehicle.Vehicle; if (vehicleToAddEnergy.EngineOfVehicle.EngineType != Engine.eEngineType.Fuel) { throw new ArgumentException(string.Format("Invalid input. The type of engine of this vehicle is not Electric{0}", Environment.NewLine)); } FuelEngine fuelEngine = (FuelEngine)vehicleToAddEnergy.EngineOfVehicle; try { fuelEngine.Refuel(i_AmountToFill, i_TypeOfFuel); vehicleToAddEnergy.EngineOfVehicle = fuelEngine; } catch (ArgumentException exception) { throw exception; } catch (OutOfRangeException exception) { throw exception; } }
private void displayFullDataOfVehicle() { string licenseNumber = inputLicenseNumber(); VehicleInGarage vehiclesInGarage = m_Garage.GetFullDataOfVehicle(licenseNumber); printForDataOfVehicle(vehiclesInGarage); }
internal static bool checkIfValidVehicleLicenseNumAndEnergy(string i_EnergyType, out Vehicle o_Vehicle, ref Garage io_Garage) { string licenseNum; bool check = UI.getLicenseNumFromUser(out licenseNum, ref io_Garage); bool checkIfCorrectEnergyType = false; Vehicle vehicleResult = null; if (check) { VehicleInGarage vehicleInGarage = io_Garage.GetVehicleInGarage(licenseNum); vehicleResult = vehicleInGarage.GetVehicle; if ((i_EnergyType == "Fuel" && !(vehicleResult.Energy is Fuel)) || (i_EnergyType == "Electricity" && !(vehicleResult.Energy is Electricity))) { System.Console.WriteLine(@"This license number has a different energy source! Please try another vehicle license number of energy source. "); } else { check = true; checkIfCorrectEnergyType = true; } } o_Vehicle = vehicleResult; return(check && checkIfCorrectEnergyType); }
private void putNewVehicleInGarage() { VehicleInGarage vehiclesInGarage = getDetailsOfVehicleInGarage(); string modelName = inputModleName(); string licenseNumber = inputLicenseNumber(); float percentageOfEnergyLeft = inputPercentageOfEnergyLeft(); eVehicleWheels WheelsByVehicleType = inputGeneralTypeOfVehicle(); List <Wheel> wheels = inputListOfWheels(WheelsByVehicleType); switch (WheelsByVehicleType) { case eVehicleWheels.motorcycle: putNewMotorcycleInGarage(licenseNumber, modelName, percentageOfEnergyLeft, vehiclesInGarage, wheels); break; case eVehicleWheels.car: putNewCarInGarage(licenseNumber, modelName, percentageOfEnergyLeft, vehiclesInGarage, wheels); break; case eVehicleWheels.truck: putNewTruckInGarage(licenseNumber, modelName, percentageOfEnergyLeft, vehiclesInGarage, wheels); break; default: Console.WriteLine("We do not handle this type of vehicle"); break; } }
private void addMotorcycle(string i_LicensePlate, string i_OwnerName, string i_OwnerPhoneNumber) { string userChoice; string modelName; bool correctChoice; Motorcycle.eMotorcycleLicenseType licenseType; List <string> tireManufacturer; int engineVolume; List <float> airPressure; Vehicle motorcycle = null; Console.WriteLine("Please enter the model name of the motorcycle:"); modelName = Console.ReadLine(); Console.WriteLine("Please enter the names of all the tires manufacturers:"); tireManufacturer = createTireManufacturerList(Motorcycle.NumOfTires); airPressure = checkAndCreateAirPressureList(Motorcycle.NumOfTires, Motorcycle.MaxTirePressure); do { Console.WriteLine("Please choose the license type of the motorcycle:"); printEnumNames(typeof(Motorcycle.eMotorcycleLicenseType)); userChoice = Console.ReadLine(); correctChoice = Enum.IsDefined(typeof(Motorcycle.eMotorcycleLicenseType), userChoice); if (correctChoice == false) { Console.WriteLine("Invalid input."); } }while (correctChoice == false); Enum.TryParse <Motorcycle.eMotorcycleLicenseType>(userChoice, out licenseType); do { Console.WriteLine("Please enter the engine volume:"); userChoice = Console.ReadLine(); }while (int.TryParse(userChoice, out engineVolume) == false); userChoice = checkAndChoosePowersource(); if (userChoice == "Battery") { motorcycle = VehicleFactory.CreateVehicle(i_LicensePlate, VehicleFactory.eVehicleType.ElectricMotorcycle, modelName, airPressure, tireManufacturer, engineVolume, licenseType); } else if (userChoice == "Fuel") { motorcycle = VehicleFactory.CreateVehicle(i_LicensePlate, VehicleFactory.eVehicleType.FueledMotorcycle, modelName, airPressure, tireManufacturer, engineVolume, licenseType); } VehicleInGarage carInGarage = new VehicleInGarage(i_OwnerName, i_OwnerPhoneNumber, motorcycle); m_Garage.AddVehicleToGarage(carInGarage); }
private VehicleInGarage getDetailsOfVehicleInGarage() { Console.WriteLine("please enter customer name"); string customerName = Console.ReadLine(); Console.WriteLine("please enter customer phone"); string customerPhone = Console.ReadLine(); VehicleInGarage vehicleInGarage = new VehicleInGarage(customerName, customerPhone, null); return(vehicleInGarage); }
private void addTruck(string i_LicensePlate, string i_OwnerName, string i_OwnerPhoneNumber) { string modelName; bool correctChoice; bool cooledTrunk = false; float trunkVolume = 0f; List <string> tireManufacturer; List <float> airPressure; Vehicle truck = null; Console.WriteLine("Please enter the model name of the truck:"); modelName = Console.ReadLine(); Console.WriteLine("Please enter the names of all the tires manufacturers:"); tireManufacturer = createTireManufacturerList(Truck.NumOfTires); airPressure = checkAndCreateAirPressureList(Truck.NumOfTires, Truck.MaxTirePressure); do { Console.WriteLine("Type true for cooled trunk, false else"); try { cooledTrunk = bool.Parse(Console.ReadLine()); correctChoice = true; } catch (FormatException) { Console.WriteLine("Please enter valid value."); correctChoice = false; } }while (correctChoice == false); do { Console.WriteLine("Please enter the trunk volume:"); try { trunkVolume = float.Parse(Console.ReadLine()); correctChoice = true; } catch (FormatException) { correctChoice = false; Console.WriteLine("Please enter a valid value."); } }while (correctChoice == false); truck = VehicleFactory.CreateVehicle(i_LicensePlate, VehicleFactory.eVehicleType.Truck, modelName, airPressure, tireManufacturer, cooledTrunk, trunkVolume); VehicleInGarage carInGarage = new VehicleInGarage(i_OwnerName, i_OwnerPhoneNumber, truck); m_Garage.AddVehicleToGarage(carInGarage); }
private void inflateWheelsInVehicle() { string licenseNum; bool check = getLicenseNumFromUser(out licenseNum, ref m_Garage);//ref not needed if (check) { VehicleInGarage vehicleInGarage = m_Garage.GetVehicleInGarage(licenseNum); vehicleInGarage.InflateAllWheels(); System.Console.Clear(); } }
private void printForDataOfVehicle(VehicleInGarage i_VehiclesInGarage) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(string.Format( @"- View full data of a vehicle - Customer Name : {0} Status Of Vehicle In Garage : {1}", i_VehiclesInGarage.CustomerName, i_VehiclesInGarage.VehicleStatus)); stringBuilder.Append(i_VehiclesInGarage.CustomerVehicle.ToString()); Console.WriteLine(stringBuilder); }
internal static void DisplayVehicleInformation(string i_LicenseNumber) { StringBuilder stringBuilder = new StringBuilder(); VehicleInGarage vehicleToDisplay = ListVehiclesInGarage[i_LicenseNumber]; List <string> listOfVehicleDetails = vehicleToDisplay.GetAllVehicleDetails(); stringBuilder.AppendLine(string.Format("The details of the vehicle with the license number: {0}{1}", i_LicenseNumber, Environment.NewLine)); foreach (string strToDisplay in listOfVehicleDetails) { stringBuilder.AppendLine(strToDisplay); } Console.WriteLine(stringBuilder.ToString()); }
private void showVehicleFullDetails() { string license = string.Empty; if (findVehicleByLicenseNumber(ref license)) { VehicleInGarage vehicle = m_GarageManager.GetVehicleByLicense(license); Console.WriteLine(vehicle.ToString()); } else { Console.WriteLine("License number is incorrect, going back to main menu"); return; } }
private void addVehicleToGarage() { Console.Clear(); string licensePlateStr = licensePlateInput(); checkBackToMainMenu(licensePlateStr); if (m_GarageModel.IsVehicleInGarage(licensePlateStr)) { m_GarageModel.ChangeVehicleStatus(licensePlateStr, VehicleInGarage.eStatus.InRepair); Console.WriteLine("There is already vehicle with this license plate in the garage, his status changed to InRepair now."); System.Threading.Thread.Sleep(3000); } else // new vehicle { // preparing the vehicle VehicleInGarage vehicleInGarageToAdd; VehicleOwner ownerInfo; Vehicle vehicleInfo = null; ownerInfo = ownerInput(); vehicleInfo = vehicleInput(licensePlateStr); // Create specific vehicle properties: if (vehicleInfo is Car) { carProperties(vehicleInfo as Car); } else if (vehicleInfo is Motorcycle) { motorcycleProperties(vehicleInfo as Motorcycle); } else // truck { truckProperties(vehicleInfo as Truck); } // Add the vehicle to the garage: vehicleInGarageToAdd = new VehicleInGarage(ownerInfo, vehicleInfo); m_GarageModel.AddVehical(vehicleInGarageToAdd); Console.WriteLine("Vehicle added successfully."); System.Threading.Thread.Sleep(2500); } }
internal static bool getLicenseNumFromUser(out string o_LicenseNum, ref Garage io_Garage) { System.Console.WriteLine("Please enter a license number:"); o_LicenseNum = null; bool check = false; string userInput = System.Console.ReadLine(); VehicleInGarage vehicleInGarage = io_Garage.GetVehicleInGarage(userInput); if (vehicleInGarage == null) { System.Console.WriteLine(@"License number does not exist in the garage! "); } else { o_LicenseNum = userInput; check = true; } return(check); }
internal static void ChargeElectricVehicle(string i_VehicleLicenseNumber, float i_AmountToFill) { VehicleInGarage currentVehicle = ListVehiclesInGarage[i_VehicleLicenseNumber]; Vehicle vehicleToAddEnergy = currentVehicle.Vehicle; if (vehicleToAddEnergy.EngineOfVehicle.EngineType != Engine.eEngineType.Electric) { throw new ArgumentException(string.Format("Invalid input. The type of engine of this vehicle is not Electric{0}", Environment.NewLine)); } ElectricEngine electricEngine = (ElectricEngine)vehicleToAddEnergy.EngineOfVehicle; try { electricEngine.Charge(i_AmountToFill); vehicleToAddEnergy.EngineOfVehicle = electricEngine; } catch (OutOfRangeException exception) { throw exception; } }
private void changeVehicleStatus() { bool isEmpty = false; isEmpty = m_Garage.IsEmpty(); if (isEmpty) { System.Console.WriteLine(@"No vehicles in the garage! Please add a vehicle first. "); } else { string licenseNum; bool check = getLicenseNumFromUser(out licenseNum, ref m_Garage); if (check) { VehicleInGarage vehicleInGarage = m_Garage.GetVehicleInGarage(licenseNum); System.Console.WriteLine("Please enter a status (like 'Repaired', 'Payed_for' etc):"); licenseNum = System.Console.ReadLine(); check = false; while (!check) { try { vehicleInGarage.Status = licenseNum; check = true; } catch (ArgumentException e) { System.Console.WriteLine(@"Invalid status! Please enter a valid status for the vehicle."); licenseNum = System.Console.ReadLine(); } } } System.Console.Clear(); } }
private void putNewFuelTruckInGarage(string i_ModelName, string i_LicenseNumber, float i_PercentageOfEnergyLeft, bool i_IsTheTrunkCooled, float i_TrunkVolume, VehicleInGarage i_VehiclesInGarage, List <Wheel> i_Wheels) { eFuelType fuelType = FuelTruck.k_FuelType; float maxFuelInLiter = FuelTruck.k_MaxFuelInLiter; float currentFuelAmount = inputCurrentFuelAmount(maxFuelInLiter); FuelEngine fuelEngine = m_VehicleManufacturer.createNewFuelEngine(fuelType, currentFuelAmount, maxFuelInLiter); FuelTruck fuelTruck = m_VehicleManufacturer.createNewFuelTruck(fuelEngine, i_ModelName, i_LicenseNumber, i_PercentageOfEnergyLeft, i_IsTheTrunkCooled, i_TrunkVolume, i_Wheels); i_VehiclesInGarage.CustomerVehicle = fuelTruck; m_Garage.PutANewCarIntoTheGarage(i_VehiclesInGarage); }
private void putNewElectricCarInGarage(string i_LicenseNumber, string i_ModelName, float i_PercentageOfEnergyLeft, eCarColor i_CarColor, eNumberOfDoors i_NumberOfDoors, VehicleInGarage i_VehicleInGarage, List <Wheel> i_Wheels) { float maxBbatteryTimeInHours = ElectricCar.k_MaxBbatteryTimeInHours; float batteryTimeInHoursLeft = inputBatteryTimeInHoursLeft(maxBbatteryTimeInHours); ElectricEngine electricEngine = m_VehicleManufacturer.createNewElectricEngine(batteryTimeInHoursLeft, maxBbatteryTimeInHours); ElectricCar electricCar = m_VehicleManufacturer.CreateNewElectricCar(electricEngine, i_NumberOfDoors, i_CarColor, i_ModelName, i_LicenseNumber, i_PercentageOfEnergyLeft, i_Wheels); i_VehicleInGarage.CustomerVehicle = electricCar; m_Garage.PutANewCarIntoTheGarage(i_VehicleInGarage); }
private static void displayAllDetailsOfVehicle(string i_LicensePlateNumber, Garage i_Garage) { VehicleInGarage requestedVehicle = i_Garage.SearchForVehicleInGarage(i_LicensePlateNumber); if (requestedVehicle != null) { string status = requestedVehicle.GetVehicleStatusInString(); bool isFuelEngine = requestedVehicle.TheVehicle.VehicleEngine is FuelEngine; bool isCar = requestedVehicle.TheVehicle is Car; bool isMotorCycle = requestedVehicle.TheVehicle is Motorcycle; Console.WriteLine( @"License plate number is: {0} Model name: {1} Owners name: {2} Owners Phone number: {3} Vehicle status: {4}", requestedVehicle.TheVehicle.LicensePlateNumber, requestedVehicle.TheVehicle.ModelName, requestedVehicle.OwnersName, requestedVehicle.OwnnersPhoneNumber, status); displayWheelsDetails(requestedVehicle.TheVehicle.VehicleWheels); if (isFuelEngine) { FuelEngine vehicleEngine = requestedVehicle.TheVehicle.VehicleEngine as FuelEngine; Console.WriteLine( @"Current Amount of fuel: {0} Fuel Type: {1}", requestedVehicle.TheVehicle.VehicleEngine.CurrentAmountOfEnergy, vehicleEngine.GetFuelTypeInString()); } else { ElectricEngine vehicleEngine = requestedVehicle.TheVehicle.VehicleEngine as ElectricEngine; if (vehicleEngine != null) { Console.WriteLine( @"Time left in battery: {0}", vehicleEngine.CurrentAmountOfEnergy); } } if (isCar) { Car vehicleType = requestedVehicle.TheVehicle as Car; if (vehicleType != null) { Console.WriteLine( @"Color: {0} Number Of Doors: {1}", vehicleType.GetColorInString(), (int)vehicleType.NumbersOfDoors); } } else if (isMotorCycle) { Motorcycle vehicleType = requestedVehicle.TheVehicle as Motorcycle; if (vehicleType != null) { Console.WriteLine( @"License Type: {0} Engine volume: {1}", vehicleType.GetLicenseTypeInString(), vehicleType.EngineVolume); } } else { Truck vehicleType = requestedVehicle.TheVehicle as Truck; if (vehicleType != null) { string isCooled = "No"; if (vehicleType.IsTrankCooled) { isCooled = "YES"; } Console.WriteLine( @"Is trunk cooled: {0} Trunk volume: {1}", isCooled, vehicleType.TrankVolume); } } } else { Console.WriteLine("vehicle not found"); } }
private void putNewFuelCarInGarage(string i_LicenseNumber, string i_ModelName, float i_PercentageOfEnergyLeft, eCarColor carColor, eNumberOfDoors i_NumberOfDoors, VehicleInGarage i_VehicleInGarage, List <Wheel> i_Wheels) { eFuelType fuelType = FuelCar.k_FuelType; float maxFuelInLiter = FuelCar.k_MaxFuelInLiter; float currentFuelAmount = inputCurrentFuelAmount(maxFuelInLiter); FuelEngine fuelEngine = m_VehicleManufacturer.createNewFuelEngine(fuelType, currentFuelAmount, maxFuelInLiter); FuelCar fuelCar = m_VehicleManufacturer.CreateNewFuelCar(fuelEngine, i_NumberOfDoors, carColor, i_ModelName, i_LicenseNumber, i_PercentageOfEnergyLeft, i_Wheels); i_VehicleInGarage.CustomerVehicle = fuelCar; m_Garage.PutANewCarIntoTheGarage(i_VehicleInGarage); }
public void Start() { m_Garage = new Garage(); while (true) { int userOp = getOp(); Console.Clear(); switch (userOp) { case 1: InsertUI.Insert(ref m_Garage); break; case 2: displayVehicles(); break; case 3: changeVehicleStatus(); break; case 4: inflateWheelsInVehicle(); break; case 5: Vehicle vehicleFuel; bool checkFuel = EnergyUI.checkIfValidVehicleLicenseNumAndEnergy("Fuel", out vehicleFuel, ref m_Garage); if (checkFuel) { Fuel fuel = vehicleFuel.Energy as Fuel; string fuelTypeToAdd = EnergyUI.askForFuelTypeToAdd(); float amountToRefuel = EnergyUI.askForAmount("Fuel"); try { fuel.Refuel(amountToRefuel, fuelTypeToAdd); } catch (ArgumentException) { System.Console.WriteLine(string.Format(@"Wrong type of fuel! This vehicle has fuel of type {0}. ", vehicleFuel.FuelType)); } catch (ValueOutOfRangeException) { System.Console.WriteLine(@"You added too much fuel or a negative amount of fuel! "); } } break; case 6: Vehicle vehicleElect; bool checkElect = EnergyUI.checkIfValidVehicleLicenseNumAndEnergy("Electricity", out vehicleElect, ref m_Garage); if (checkElect) { Electricity electricity = vehicleElect.Energy as Electricity; float amountToRecharge = EnergyUI.askForAmount("Electricity"); electricity.Recharge(amountToRecharge); } break; case 7: string licenseNum; bool check = getLicenseNumFromUser(out licenseNum, ref m_Garage); if (check) { VehicleInGarage vehicleInGarage = m_Garage.GetVehicleInGarage(licenseNum); System.Console.WriteLine(vehicleInGarage); } break; } } }
private void putNewMotorcycleInGarage(string i_LicenseNumber, string i_ModelName, float i_PercentageOfEnergyLeft, VehicleInGarage i_VehiclesInGarage, List <Wheel> i_Wheels) { eLicenseType licenseType = inputLicenseType(); int engineCapacity = inputEngineCapacity(); Console.WriteLine(string.Format( @"- Choose the type of your motorcycle you want - for fuel engine motorcycle -> Press 1 for electric engine motorcycle -> Press any other key")); string choise = Console.ReadLine(); if (choise == "1") { putNewFuelEngineMotorcycle(i_LicenseNumber, i_ModelName, i_PercentageOfEnergyLeft, licenseType, engineCapacity, i_VehiclesInGarage, i_Wheels); } else { putNewElectricEngineMotorcycle(i_LicenseNumber, i_ModelName, i_PercentageOfEnergyLeft, licenseType, engineCapacity, i_VehiclesInGarage, i_Wheels); } }
private void putNewElectricEngineMotorcycle(string i_LicenseNumber, string i_ModelName, float i_PercentageOfEnergyLeft, eLicenseType i_LicenseType, int i_EngineCapacity, VehicleInGarage i_VehiclesInGarage, List <Wheel> i_Wheels) { float maxBbatteryTimeInHours = ElectricMotorcycle.k_MaxBbatteryTimeInHours; float batteryTimeInHoursLeft = inputBatteryTimeInHoursLeft(maxBbatteryTimeInHours); ElectricEngine electricEngine = m_VehicleManufacturer.createNewElectricEngine(batteryTimeInHoursLeft, maxBbatteryTimeInHours); ElectricMotorcycle electricMotorcycle = m_VehicleManufacturer.createNewElectricMotorcycle(electricEngine, i_LicenseType, i_EngineCapacity, i_ModelName, i_LicenseNumber, i_EngineCapacity, i_Wheels); i_VehiclesInGarage.CustomerVehicle = electricMotorcycle; m_Garage.PutANewCarIntoTheGarage(i_VehiclesInGarage); }
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); }
private void putNewCarInGarage(string i_LicenseNumber, string i_ModelName, float i_PercentageOfEnergyLeft, VehicleInGarage i_VehicleInGarage, List <Wheel> i_Wheels) { eCarColor carColor = inputCarColor(); eNumberOfDoors numberOfDoors = inputNumberOfDoors(); Console.WriteLine(string.Format(@"choose the type of vehicle you want: for fuel engine car - press 1 for electric engine car - press any other key")); string choice = Console.ReadLine(); if (choice == "1") { putNewFuelCarInGarage(i_LicenseNumber, i_ModelName, i_PercentageOfEnergyLeft, carColor, numberOfDoors, i_VehicleInGarage, i_Wheels); } else { putNewElectricCarInGarage(i_LicenseNumber, i_ModelName, i_PercentageOfEnergyLeft, carColor, numberOfDoors, i_VehicleInGarage, i_Wheels); } }
private void putNewTruckInGarage(string i_LicenseNumber, string i_ModelName, float i_PercentageOfEnergyLeft, VehicleInGarage i_VehiclesInGarage, List <Wheel> i_Wheels) { Console.WriteLine(string.Format(@"This garage only handles trucks with fuel")); bool isTheTrunkCooled = inputIsTheTrunkCooled(); float trunkVolume = inputTrunkVolume(); putNewFuelTruckInGarage(i_ModelName, i_LicenseNumber, i_PercentageOfEnergyLeft, isTheTrunkCooled, trunkVolume, i_VehiclesInGarage, i_Wheels); }
private void putNewFuelEngineMotorcycle(string i_LicenseNumber, string i_ModelName, float i_PercentageOfEnergyLeft, eLicenseType i_LicenseType, int i_EngineCapacity, VehicleInGarage i_VehiclesInGarage, List <Wheel> i_Wheels) { eFuelType fuelType = FuelMotorcycle.k_FuelType; float maxFuelInLiter = FuelMotorcycle.k_MaxFuelInLiter; float currentFuelAmount = inputCurrentFuelAmount(maxFuelInLiter); FuelEngine fuelEngine = m_VehicleManufacturer.createNewFuelEngine(fuelType, currentFuelAmount, maxFuelInLiter); FuelMotorcycle fuelMotorcycle = m_VehicleManufacturer.CreateNewFuelMotorcycle(fuelEngine, i_LicenseType, i_EngineCapacity, i_ModelName, i_LicenseNumber, i_PercentageOfEnergyLeft, i_Wheels); i_VehiclesInGarage.CustomerVehicle = fuelMotorcycle; m_Garage.PutANewCarIntoTheGarage(i_VehiclesInGarage); }