Пример #1
0
        public void Refuel(string i_LicenseNumber, float i_AmountToAdd, FuelTank.eFuelType i_FuelType)
        {
            EnergySource.eEnergySourceType energyType = EnergySource.eEnergySourceType.Fuel;

            checkIfVehicleInGarage(i_LicenseNumber);
            checkIfFillEnergyActionSuitableToEnergySource(i_LicenseNumber, energyType);
            (r_Vehicles[i_LicenseNumber].Vehicle.EnergySource as FuelTank).Refuel(i_AmountToAdd, i_FuelType);
        }
Пример #2
0
        public void ChargeTheBattery(string i_LicenseNumber, float i_AmountToAdd)
        {
            EnergySource.eEnergySourceType energyType = EnergySource.eEnergySourceType.Electricbattery;

            checkIfVehicleInGarage(i_LicenseNumber);
            checkIfFillEnergyActionSuitableToEnergySource(i_LicenseNumber, energyType);
            (r_Vehicles[i_LicenseNumber].Vehicle.EnergySource as ElectricBattery).Charge(i_AmountToAdd);
        }
Пример #3
0
 public Car(string i_Manufacturer, string i_PlateLicenseNumber, float i_RemainingEnergy,
            EnergySource.eEnergySourceType i_EnergyType, string i_WheelsManufacturName, float i_CurrentWheelsAirPressure) :
     base(i_Manufacturer, i_PlateLicenseNumber, i_RemainingEnergy, k_NumberOfWheels,
          k_MaxAirPressure, i_EnergyType, i_WheelsManufacturName, i_CurrentWheelsAirPressure)
 {
     m_CarColor      = new eCarColor();
     m_NumberOfDoors = new eNumberOfDoors();
 }
Пример #4
0
 public Truck(string i_Manufacturer, string i_PlateLicenseNumber, float i_RemainingEnergy,
              EnergySource.eEnergySourceType i_EnergyType, string i_WheelsManufacturName, float i_CurrentWheelsAirPressure) :
     base(i_Manufacturer, i_PlateLicenseNumber, i_RemainingEnergy, k_NumberOfWheels,
          k_MaxAirPressure, i_EnergyType, i_WheelsManufacturName, i_CurrentWheelsAirPressure)
 {
     m_MaxCarryingWeight            = 0;
     m_IsCarryingHazardousMaterials = false;
 }
Пример #5
0
 public Motorcycle(string i_Manufacturer, string i_PlateLicenseNumber, float i_RemainingEnergy,
                   EnergySource.eEnergySourceType i_EnergyType, string i_WheelsManufacturName, float i_CurrentWheelsAirPressure) :
     base(i_Manufacturer, i_PlateLicenseNumber, i_RemainingEnergy, k_NumberOfWheels,
          k_MaxAirPressure, i_EnergyType, i_WheelsManufacturName, i_CurrentWheelsAirPressure)
 {
     m_EngineDisplacement = 0;
     m_LicenseType        = new eLicenseType();
 }
Пример #6
0
 protected Vehicle(string i_Manufacturer, string i_PlateLicenseNumber, float i_RemainingEnergyPrecentage,
                   int i_NumberOfWheels, float i_MaxAirPressure, EnergySource.eEnergySourceType i_EnergyType,
                   string i_WheelsManufacturName, float i_WheelsCurrentAirPressurePrecentage)
 {
     m_ManufacturName     = i_Manufacturer;
     m_PlateLicenseNumber = i_PlateLicenseNumber;
     m_Wheels             = new List <Wheel>(i_NumberOfWheels);
     setWheels(i_WheelsManufacturName, i_WheelsCurrentAirPressurePrecentage, i_MaxAirPressure, i_NumberOfWheels);
     if (i_EnergyType == EnergySource.eEnergySourceType.Fuel)
     {
         m_EnergySource = new FuelTank();
     }
     else
     {
         m_EnergySource = new ElectricBattery();
     }
     setEnergySource(i_RemainingEnergyPrecentage);
 }
Пример #7
0
        private EnergySource.eEnergySourceType getEnergySource(Vehicle.eVehicleType i_TypeOfVehicle)
        {
            bool   isTruck = i_TypeOfVehicle == Vehicle.eVehicleType.Truck;
            string stringToPrint;

            EnergySource.eEnergySourceType energyType = new EnergySource.eEnergySourceType();

            if (!isTruck)
            {
                stringToPrint = "Please choose the energy source:";
                UI.PrintString(stringToPrint);
                energyType = (EnergySource.eEnergySourceType)UI.GetInputAccordingToEnum(energyType);
            }
            else
            {
                energyType = EnergySource.eEnergySourceType.Fuel;
            }

            return(energyType);
        }
Пример #8
0
        private void checkIfFillEnergyActionSuitableToEnergySource(string i_LicenseNumber, EnergySource.eEnergySourceType i_TypeOfRequest)
        {
            bool isSuitableAction, isFuelVehicle;

            isFuelVehicle = r_Vehicles[i_LicenseNumber].Vehicle.EnergySource is FuelTank;
            if (i_TypeOfRequest == EnergySource.eEnergySourceType.Fuel)
            {
                isSuitableAction = isFuelVehicle;
            }
            else
            {
                isSuitableAction = !isFuelVehicle;
            }

            if (!isSuitableAction)
            {
                string errorMessage;
                if (isFuelVehicle)
                {
                    errorMessage = "Cannot Charge vehicle with fuel tank";
                }
                else
                {
                    errorMessage = "Cannot fuel vehicle with electric battery";
                }
                throw new ArgumentException(errorMessage);
            }
        }
Пример #9
0
        public static Vehicle CreateTheVehicle(Vehicle.eVehicleType i_VehicleType, string i_ManufacturName,
                                               string i_LicenseNumber, float i_RemainingEnergy, EnergySource.eEnergySourceType i_SourceType,
                                               string i_WheelsManufacturName, float i_WheelsCurrentAirPressurePrecentage)
        {
            Vehicle vehicleToCreate = null;

            // Check the vehicle type, and create a new instance of it
            switch (i_VehicleType)
            {
            case Vehicle.eVehicleType.Car:
                vehicleToCreate = new Car(i_ManufacturName, i_LicenseNumber, i_RemainingEnergy, i_SourceType, i_WheelsManufacturName, i_WheelsCurrentAirPressurePrecentage);
                break;

            case Vehicle.eVehicleType.MotorCycle:
                vehicleToCreate = new Motorcycle(i_ManufacturName, i_LicenseNumber, i_RemainingEnergy, i_SourceType, i_WheelsManufacturName, i_WheelsCurrentAirPressurePrecentage);
                break;

            case Vehicle.eVehicleType.Truck:
                vehicleToCreate = new Truck(i_ManufacturName, i_LicenseNumber, i_RemainingEnergy, i_SourceType, i_WheelsManufacturName, i_WheelsCurrentAirPressurePrecentage);
                break;
            }

            return(vehicleToCreate);
        }