Example #1
0
        public Tank(FuelVolume capacity, FuelVolume remaining)
        {
            if (capacity < remaining)
            {
                throw new InvalidOperationException($"Capacity {capacity} should be more than {remaining}");
            }

            this.capacity  = capacity;
            this.remaining = remaining;
        }
Example #2
0
        public void Fill(FuelVolume volume)
        {
            var newVolume = remaining + volume;

            if (capacity < newVolume)
            {
                throw new InvalidOperationException($"Not enough capacity");
            }

            remaining = FuelVolume.From(newVolume);
        }
Example #3
0
 public void Consume(FuelVolume volume)
 {
     //Validation value < 0 is already implemented in the FuelVolume
     remaining = remaining - volume;
 }