using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClassCounts
{
/// <summary>
/// Счётчик с заданным диапазоном значений
/// </summary>
internal class Counter
{
private int _upperLimit; // верхняя граница
private int _lowerLimit; // нижняя граница
private int _currentStatus; // текущее состояние
public string _errorCode; // сообщение об ошибки
public Counter()
{
this._upperLimit = 10;
this._lowerLimit = 0;
this._currentStatus = 0;
}
public int StatusCurrent
{
get
{
return this._currentStatus;
}
}
/// <summary>
/// Метод увеличения счётчика на 1
/// </summary>
public void IncrementCount()
{
if (_currentStatus + 1 > _upperLimit)
{
this._currentStatus = this._upperLimit;
this._errorCode = ("Превышено допустимое значение");
}
_currentStatus ++;
}
/// <summary>
/// Метод уменьшения счётчика на 1
/// </summary>
public void DecrementCount()
{
if (_currentStatus - 1 < _lowerLimit)
{
this._currentStatus = this._lowerLimit;
this._errorCode = ("Значение ниже допустимого");
}
_currentStatus --;
}
}
}