struct Cycle
{
// Private fields
int _val, _min, _max;
// Constructor
public Cycle(int min, int max)
{
_val = min;
_min = min;
_max = max;
}
public int Value
{
get { return _val; }
set
{
if (value > _max)
this.Value = value - _max + _min - 1;
else
{
if (value < _min)
this.Value = _min - value + _max - 1;
else
_val = value;
}
}
}
public override string ToString()//what?
{
return Value.ToString();
}
public int ToInteger()
{
return Value;
}
public static Cycle operator +(Cycle arg1, int arg2)//What ?
{
arg1.Value += arg2;
return arg1;
}
public static Cycle operator -(Cycle arg1, int arg2)//What?
{
arg1.Value -= arg2;
return arg1;
}
}
//
Cycle degrees = new Cycle(0, 359);
Cycle quarters = new Cycle(1, 4);
for (int i = 0; i <= 8; i++)
{
degrees += 90; quarters += 1;
Console.WriteLine("degrees = {0}, quarters = {1}", degrees, quarters);
}