예제 #1
0
 private Incrementor(Incrementor related, int min, int max, int increment, int currentValue)
 {
     _related     = related;
     Minimum      = min;
     Maximum      = max;
     Increment    = increment;
     Value        = currentValue;
     CanIncrement = IsIncrementable();
 }
예제 #2
0
        public Incrementor IncrementValue()
        {
            if (!CanIncrement)
            {
                throw new InvalidOperationException();
            }

            if (Value == Maximum)
            {
                if (_related != null)
                {
                    _related = _related.IncrementValue();
                }
                return(new Incrementor(_related, Minimum, Maximum, Increment));
            }

            return(new Incrementor(_related, Minimum, Maximum, Increment, Value + Increment));
        }
예제 #3
0
 public Incrementor SetParent(Incrementor parentIncrementor)
 {
     return(new Incrementor(parentIncrementor, Minimum, Maximum, Increment));
 }
예제 #4
0
 public Incrementor(Incrementor related, int min, int max, int increment = 1)
     : this(related, min, max, increment, min)
 {
 }