/* public void Refuel(string i_licenseNumber, FuelEngine.eFuelType i_fuelType, float i_fuelAmount) * { * Vehicle vehicle = getVehicleOfType(i_licenseNumber, typeof(FuelEngine.eFuelType)); * CreateVehicle.eVehicleType vehicleType * * * }*/ public Vehicle getVehicleOfType(string i_licenseNumber, CreateVehicle.eVehicleType i_vehicleType) { Vehicle vehicle = m_currentGarageVehicles[i_licenseNumber]; if (!vehicle.GetType().Equals(i_vehicleType)) { throw new InvalidVehicleTypeException(); } return(vehicle); }
public void AddCarToGarage(string i_OwnerName, string i_OwnerPhone, string i_LicenseNumber, int i_VehicleType) { Vehicle newVehicle; CreateVehicle.eVehicleType vehicleType = (CreateVehicle.eVehicleType)i_VehicleType; if (IsLicenseInGarage(i_LicenseNumber)) { throw new ArgumentException("The vehicle already exists in the garage!"); } else { newVehicle = CreateVehicle.createVehicle(vehicleType, i_LicenseNumber); m_CurrentVehicleInGarage = new VehicleInGarage(i_OwnerName, i_OwnerPhone, newVehicle); r_VehiclesInGarage.Add(i_LicenseNumber, m_CurrentVehicleInGarage); } }
private Dictionary <string, Object> getSpecificVehicleInformation(string i_licenseNumber, CreateVehicle.eVehicleType i_vehicleType) { Dictionary <string, Object> specificInformation = new Dictionary <string, object>(4); Console.WriteLine("Please enter the wheel manufacturer:"); specificInformation.Add("Wheel Manufacturer", System.Console.ReadLine()); switch (i_vehicleType) { case CreateVehicle.eVehicleType.ElectricCar: case CreateVehicle.eVehicleType.FuelBasedCar: Console.WriteLine("Please enter the color:"); specificInformation.Add("Color", CheckParsing(System.Console.ReadLine(), typeof(Car.eColor))); Console.WriteLine("Please enter the number of doors:"); specificInformation.Add("Number Of Doors", CheckParsing(System.Console.ReadLine(), typeof(Car.eCarNumberOfDoors))); break; case CreateVehicle.eVehicleType.ElectricMotorcycle: case CreateVehicle.eVehicleType.FuelBasedMotorcycle: Console.WriteLine("Please enter the license type"); specificInformation.Add("License", CheckParsing(System.Console.ReadLine(), typeof(Motorcycle.eLicense))); Console.WriteLine("Please enter the engine volume:"); specificInformation.Add("Engine Volume", CheckParsing(System.Console.ReadLine(), typeof(int))); break; case CreateVehicle.eVehicleType.FuelBasedTruck: Console.WriteLine("Please enter if the car is cooled (Y/N)"); specificInformation.Add("Is Cooled", CheckParsing(System.Console.ReadLine(), typeof(bool))); Console.WriteLine("Please enter the cargo volume"); specificInformation.Add("Cargo Volume", CheckParsing(System.Console.ReadLine(), typeof(float))); break; default: throw new ArgumentException(); } return(specificInformation); }
private void addNewVehicleToGarage() { string licensePlate = m_UserInputs.getLicensePlate(); float maxAirPressure = 0; float maxBatteryTime = 0; FuelVehicle.eFuelType fuelType; Vehicle.eTireAmount tireAmount; if (m_Garage.m_AllVehiclesInTheGarage.ContainsKey(licensePlate)) { m_Garage.changeVehicleStatus(licensePlate, Client.eVehicleStatus.Repairing); m_UserInputs.vehicleAlreadyInGarageMessage(); } else { string vehicleModel = m_UserInputs.getValidString("Please enter vehicle model name:"); string ownerName = m_UserInputs.getValidString("Please enter Owner Name"); string ownerPhone = m_UserInputs.getOwnerPhone(); float percentOfRemainingEnergy = 0; Client newClient = null; CreateVehicle.eVehicleType vehicleType = (CreateVehicle.eVehicleType)m_UserInputs.getVehicleType(); string tiresManufacturer = m_UserInputs.getValidString("Please enter the tires manufacturer:"); float currentTireAirPressure; List <Tire> listOfTires; Vehicle vehicleForProperty; if (vehicleType == CreateVehicle.eVehicleType.ElectricCar || vehicleType == CreateVehicle.eVehicleType.FuelCar) { maxAirPressure = (float)Tire.eMaxAirPressure.Car; currentTireAirPressure = m_UserInputs.getTiresPressure(maxAirPressure); tireAmount = Vehicle.eTireAmount.Car; listOfTires = CreateVehicle.createListOfTires(tireAmount, tiresManufacturer, currentTireAirPressure, maxAirPressure); Car.eColor carColor = m_UserInputs.getCarColor(); Car.eNumberOfDoors numberOfDoors = m_UserInputs.getNumberOfDoors(); Car car = CreateVehicle.createCar(carColor, numberOfDoors); if (vehicleType == CreateVehicle.eVehicleType.ElectricCar) { float remainingBatteryTime = m_UserInputs.getRemainingBatteryTime(ElectricCar.k_MaxBatteryTime); percentOfRemainingEnergy = Vehicle.getPercentOfEnergy(remainingBatteryTime, ElectricCar.k_MaxBatteryTime); ElectricCar electricCar = CreateVehicle.createElectricCar(car, remainingBatteryTime, maxBatteryTime, vehicleModel, licensePlate, percentOfRemainingEnergy, listOfTires); newClient = CreateVehicle.createClient(ownerName, ownerPhone, Client.eVehicleStatus.Repairing, electricCar); } else { fuelType = FuelVehicle.eFuelType.Octan98; float currentAmountOfFuel = m_UserInputs.getCurrentAmountOfFuel(FuelCar.k_MaxAmountOfFuel); percentOfRemainingEnergy = Vehicle.getPercentOfEnergy(currentAmountOfFuel, FuelCar.k_MaxAmountOfFuel); FuelCar fuelCar = CreateVehicle.createFuelCar(car, fuelType, currentAmountOfFuel, vehicleModel, licensePlate, percentOfRemainingEnergy, listOfTires); newClient = CreateVehicle.createClient(ownerName, ownerPhone, Client.eVehicleStatus.Repairing, fuelCar); } vehicleForProperty = newClient.m_Vehicle; Car.setProperties(vehicleForProperty, carColor, numberOfDoors); } else if (vehicleType == CreateVehicle.eVehicleType.ElectricMotorcycle || vehicleType == CreateVehicle.eVehicleType.FuelMotorcycle) { maxAirPressure = (float)Tire.eMaxAirPressure.Motorcycle; currentTireAirPressure = m_UserInputs.getTiresPressure(maxAirPressure); tireAmount = Vehicle.eTireAmount.Motorcycle; listOfTires = CreateVehicle.createListOfTires(tireAmount, tiresManufacturer, currentTireAirPressure, maxAirPressure); Motorcycle.eTypeOfLicense typeOfLicense = m_UserInputs.getTypeOfLicense(); int engineCapacity = m_UserInputs.getValidInt("Please enter engine capacity:", 0, int.MaxValue); Motorcycle motorCycle = CreateVehicle.createMotorcycle(typeOfLicense, engineCapacity); if (vehicleType == CreateVehicle.eVehicleType.ElectricMotorcycle) { float remainingBatteryTime = m_UserInputs.getRemainingBatteryTime(ElectricMotorcycle.k_MaxBatteryTime); percentOfRemainingEnergy = Vehicle.getPercentOfEnergy(remainingBatteryTime, ElectricMotorcycle.k_MaxBatteryTime); ElectricMotorcycle electricMotorcycle = CreateVehicle.createElectricMotorcycle(motorCycle, remainingBatteryTime, vehicleModel, licensePlate, percentOfRemainingEnergy, listOfTires); newClient = CreateVehicle.createClient(ownerName, ownerPhone, Client.eVehicleStatus.Repairing, electricMotorcycle); } else { fuelType = FuelVehicle.eFuelType.Octan95; float currentAmountOfFuel = m_UserInputs.getCurrentAmountOfFuel(FuelMotorcycle.k_MaxAmountOfFuel); percentOfRemainingEnergy = Vehicle.getPercentOfEnergy(currentAmountOfFuel, FuelMotorcycle.k_MaxAmountOfFuel); FuelMotorcycle fuelMotorcycle = CreateVehicle.createFuelMotorcycle(motorCycle, fuelType, currentAmountOfFuel, vehicleModel, licensePlate, percentOfRemainingEnergy, listOfTires); newClient = CreateVehicle.createClient(ownerName, ownerPhone, Client.eVehicleStatus.Repairing, fuelMotorcycle); } vehicleForProperty = newClient.m_Vehicle; Motorcycle.setProperties(vehicleForProperty, typeOfLicense, engineCapacity); } else if (vehicleType == CreateVehicle.eVehicleType.Truck) { maxAirPressure = (float)Tire.eMaxAirPressure.Truck; currentTireAirPressure = m_UserInputs.getTiresPressure(maxAirPressure); tireAmount = Vehicle.eTireAmount.Truck; listOfTires = CreateVehicle.createListOfTires(tireAmount, tiresManufacturer, currentTireAirPressure, maxAirPressure); fuelType = FuelVehicle.eFuelType.Soler; bool carrierDangerousMaterials = m_UserInputs.getIfCarrierDangerousMaterials(); float maximumCarryingWeight = m_UserInputs.getValidFloat("Please enter maximum carry weight:", 0, int.MaxValue); Truck truck = CreateVehicle.createTruck(carrierDangerousMaterials, maximumCarryingWeight); float currentAmountOfFuel = m_UserInputs.getCurrentAmountOfFuel(FuelTruck.k_MaxAmountOfFuel); percentOfRemainingEnergy = Vehicle.getPercentOfEnergy(currentAmountOfFuel, FuelTruck.k_MaxAmountOfFuel); FuelTruck fuelTruck = CreateVehicle.createFuelTruck(truck, fuelType, currentAmountOfFuel, vehicleModel, licensePlate, percentOfRemainingEnergy, listOfTires); newClient = CreateVehicle.createClient(ownerName, ownerPhone, Client.eVehicleStatus.Repairing, fuelTruck); vehicleForProperty = newClient.m_Vehicle; Truck.setProperties(vehicleForProperty, carrierDangerousMaterials, maximumCarryingWeight); } m_Garage.addVehicle(newClient); m_UserInputs.suceededToAddMessage(); } System.Console.ReadLine(); }