Example #1
0
        public void Recharge(string i_LicenseNumber, string i_MinuetsToCharge)
        {
            Customer customer = GetCustomer(i_LicenseNumber);

            if (!(customer.Vehicle.Engine is ElectricEngine))
            {
                throw new ArgumentException("Cannot recharge fuel engine");
            }

            float minuetsToAddToBattery = PropertiesValidation.PositiveFloatValidation(i_MinuetsToCharge);

            ((ElectricEngine)(customer.Vehicle.Engine)).Recharge(minuetsToAddToBattery / 60);
        }
        private void validationOfWheels(Dictionary <string, string> i_VehicleInfo)
        {
            float maximalAirPressure = PropertiesValidation.PositiveFloatValidation(i_VehicleInfo["Wheel maximal air pressure:"]);

            try
            {
                float currentAirPressure = PropertiesValidation.PositiveFloatValidation(i_VehicleInfo["Wheel current air pressure:"]);
                PropertiesValidation.ValidateCurrentAmount(currentAirPressure, maximalAirPressure);
            }
            catch (Exception ecxeption)
            {
                throw new ArgumentException("impossible wheel current air pressure. " + ecxeption.Message);
            }
        }
        private static void validationOfEngine(string i_CurrentEnergyAmount, string i_MaxEnergyAmount)
        {
            float MaxEnergyAmount = PropertiesValidation.PositiveFloatValidation(i_MaxEnergyAmount);

            try
            {
                float CurrentEnergyAmount = PropertiesValidation.PositiveFloatValidation(i_CurrentEnergyAmount);
                PropertiesValidation.ValidateCurrentAmount(CurrentEnergyAmount, MaxEnergyAmount);
            }
            catch (Exception ecxeption)
            {
                throw new ArgumentException("impossible current energy amount. " + ecxeption.Message);
            }
        }
Example #4
0
        public void Refuel(string i_LicenseNumber, string i_FuelType, string i_FuelAmountToAdd)
        {
            Customer customer = GetCustomer(i_LicenseNumber);

            if (!(customer.Vehicle.Engine is FuelEngine))
            {
                throw new ArgumentException("Cannot refuel electric engine");
            }

            int optionNumber = int.Parse(i_FuelType);

            FuelEngine.eFuelType fuelType = (FuelEngine.eFuelType)optionNumber;
            float amountToAdd             = PropertiesValidation.PositiveFloatValidation(i_FuelAmountToAdd);

            ((FuelEngine)(customer.Vehicle.Engine)).Refuel(amountToAdd, fuelType);
        }
Example #5
0
 internal Motorcycle(Dictionary <string, string> i_MotorcycleInfo, Engine i_Engine) : base(i_MotorcycleInfo, i_Engine)
 {
     m_LicenseType    = PropertiesValidation.EnumTryParse <eLicenseType>(i_MotorcycleInfo["License type:"], "License type");
     m_EngineCapacity = int.Parse(i_MotorcycleInfo["Engine capacity:"]);
 }
Example #6
0
 internal FuelEngine(Dictionary <string, string> i_FuelEngineInfo) : base(i_FuelEngineInfo["Current fuel amount:"], i_FuelEngineInfo["max fuel amount:"])
 {
     m_FuelType = PropertiesValidation.EnumTryParse <eFuelType>(i_FuelEngineInfo["Fuel type:"], "Fuel type");
 }
Example #7
0
 internal Car(Dictionary <string, string> i_CarInfo, Engine i_Engine) : base(i_CarInfo, i_Engine)
 {
     m_Color         = PropertiesValidation.EnumTryParse <eColor>(i_CarInfo["Car's color:"], "Car's color");
     m_NumberOfDoors = (Car.eNumberOfDoors) int.Parse(i_CarInfo["Number of doors:"]);
 }
 private void validationOfTruck(Dictionary <string, string> i_TruckInfo)
 {
     PropertiesValidation.ValidateLisenceNumber(i_TruckInfo["Lisence number:"]);
     PropertiesValidation.CheckeIfAnswerIsYesOrNo(i_TruckInfo["Carry dangerous materials:"]);
     PropertiesValidation.PositiveFloatValidation(i_TruckInfo["Carrying capacity:"]);
 }
 private void validationOfCar(Dictionary <string, string> i_CarInfo)
 {
     PropertiesValidation.ValidateLisenceNumber(i_CarInfo["Lisence number:"]);
     PropertiesValidation.EnumValidation <Car.eColor>(i_CarInfo["Car's color:"], "Car's color:");
     PropertiesValidation.ValidateNumberOfDoors(i_CarInfo["Number of doors:"]);
 }
 private void validationOfMotorcycle(Dictionary <string, string> i_MotorcycleInfo)
 {
     PropertiesValidation.ValidateLisenceNumber(i_MotorcycleInfo["Lisence number:"]);
     PropertiesValidation.EnumValidation <Motorcycle.eLicenseType>(i_MotorcycleInfo["License type:"], "license");
     PropertiesValidation.PositiveIntEngineCapaityValidation(i_MotorcycleInfo["Engine capacity:"]);
 }
 private static void validationOfFuelEngine(Dictionary <string, string> i_FuelEngineInfo)
 {
     validationOfEngine(i_FuelEngineInfo["Current fuel amount:"], i_FuelEngineInfo["max fuel amount:"]);
     PropertiesValidation.EnumValidation <FuelEngine.eFuelType>(i_FuelEngineInfo["Fuel type:"], "fuel");
 }