public bool Increment()
        {
            bool success = true;

            if (_fuelGauge.ReportLevel() > 0)
            {
                if (_mileage < _maxMileage)
                {
                    _mileage++;
                }
                else
                {
                    _mileage = 0;
                }
                if (_mileage % 10 == 0)
                {
                    _fuelGauge.DecreaseLevel();
                }
            }
            else
            {
                //throw new Exception($"fuel level: {_fuelGauge.ReportLevel()}");
                Console.WriteLine($"Fuel level: {_fuelGauge.ReportLevel()}, please refill!");
                success = false;
            }

            return(success);
        }
 public void Increment()
 {
     if (_fuelGauge.ReportLevel() > 0)
     {
         if (_mileage < _maxMileage)
         {
             _mileage++;
         }
         else
         {
             _mileage = 0;// te ir 2 dažādi if esle statement?
         }
         if (_mileage % 10 == 0)
         {
             _fuelGauge.DecreaseLevel();
         }
     }
     else//3 if else statemt?
     {
         throw new Exception(message: $"fuel level: {_fuelGauge.ReportLevel()}");// kāpēc te ir throw? nevajag catch?
     }
 }
Beispiel #3
0
        public void Increment()
        {
            if (_fuelGauge.ReportLevel() > 0)
            {
                if (_mileage < _maxMileage)
                {
                    _mileage++;
                }
                else
                {
                    _mileage = 0;
                }

                if (_mileage % 10 == 0)
                {
                    _fuelGauge.DecreaseLevel();
                }
            }
            else
            {
                throw new Exception($"no fuel");
            }
        }