48 lines
824 B
C#
48 lines
824 B
C#
|
using System;
|
|||
|
|
|||
|
namespace SBRL.Geometry
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// Represents a single 1-dimensional range.
|
|||
|
/// </summary>
|
|||
|
public class Range
|
|||
|
{
|
|||
|
public int Min { get; set; }
|
|||
|
public int Max { get; set; }
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// The difference between the minimum and the maximum number in this range.
|
|||
|
/// </summary>
|
|||
|
public int Stride {
|
|||
|
get {
|
|||
|
return Max - Min;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public Range(int min, int max)
|
|||
|
{
|
|||
|
Min = min;
|
|||
|
Max = max;
|
|||
|
|
|||
|
if (Max < Min)
|
|||
|
throw new ArgumentException("Error: The maximum provided is greater than the minimum!");
|
|||
|
}
|
|||
|
|
|||
|
public void Shift(int amount)
|
|||
|
{
|
|||
|
Min += amount;
|
|||
|
Max += amount;
|
|||
|
}
|
|||
|
public void Multiply(int multiplier)
|
|||
|
{
|
|||
|
Min *= multiplier;
|
|||
|
Max *= multiplier;
|
|||
|
}
|
|||
|
|
|||
|
public override string ToString()
|
|||
|
{
|
|||
|
return $"[Range Min={Min}, Max={Max}]";
|
|||
|
}
|
|||
|
}
|
|||
|
}
|