2024-03-27 13:30:13 +04:00
|
|
|
|
namespace ProjectLiner
|
2024-03-14 16:09:51 +04:00
|
|
|
|
{
|
2024-03-27 13:30:13 +04:00
|
|
|
|
public class Liner : GameObject
|
2024-03-14 16:09:51 +04:00
|
|
|
|
{
|
|
|
|
|
private int _speed;
|
|
|
|
|
private int _weight;
|
|
|
|
|
private Color _firstCol;
|
|
|
|
|
private Color _secondCol;
|
2024-03-27 13:30:13 +04:00
|
|
|
|
private int _numOfBoxes;
|
|
|
|
|
private bool _haveMark;
|
2024-03-14 16:09:51 +04:00
|
|
|
|
private int _step;
|
|
|
|
|
public int Speed { get => _speed;}
|
|
|
|
|
public int Weight { get => _weight;}
|
|
|
|
|
public Color FirstColor { get => _firstCol; }
|
|
|
|
|
public Color SecondColor { get => _secondCol; }
|
2024-03-27 13:30:13 +04:00
|
|
|
|
public int NumOfBoxes { get => _numOfBoxes; }
|
2024-03-14 16:09:51 +04:00
|
|
|
|
public int Step { get => _step>0?_step:1; }
|
2024-03-27 13:30:13 +04:00
|
|
|
|
public bool HasMark { get => _haveMark;}
|
|
|
|
|
public Liner()
|
2024-03-14 16:09:51 +04:00
|
|
|
|
{
|
|
|
|
|
_speed = 1;
|
|
|
|
|
_weight = 1;
|
|
|
|
|
_firstCol = Color.Magenta;
|
|
|
|
|
_secondCol = Color.Black;
|
2024-03-27 13:30:13 +04:00
|
|
|
|
_numOfBoxes = 6;
|
|
|
|
|
_haveMark = true;
|
2024-03-14 16:09:51 +04:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_step = _speed / _weight;
|
|
|
|
|
}catch(Exception e) { throw new Exception("Дурашка, какой ноль в весе?"); }
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="speed"></param>
|
|
|
|
|
/// <param name="weight">(0,int.MaxValue]</param>
|
|
|
|
|
/// <param name="firstCol"></param>
|
|
|
|
|
/// <param name="secondCol"></param>
|
2024-03-27 13:30:13 +04:00
|
|
|
|
/// <param name="numOfBoxes">[2,6]</param>
|
2024-03-14 16:09:51 +04:00
|
|
|
|
/// <exception cref="Exception"></exception>
|
2024-03-27 13:30:13 +04:00
|
|
|
|
public Liner(int speed, int weight, Color firstCol, Color secondCol, int numOfBoxes,bool haveMark)
|
2024-03-14 16:09:51 +04:00
|
|
|
|
{
|
2024-03-27 13:30:13 +04:00
|
|
|
|
if (numOfBoxes > 24||numOfBoxes<2)
|
|
|
|
|
throw new ArgumentOutOfRangeException($"{nameof(numOfBoxes)} out of range [2,24]");
|
2024-03-14 16:09:51 +04:00
|
|
|
|
_speed = speed;
|
|
|
|
|
_weight = weight;
|
|
|
|
|
_firstCol = firstCol;
|
|
|
|
|
_secondCol = secondCol;
|
2024-03-27 13:30:13 +04:00
|
|
|
|
_numOfBoxes = numOfBoxes;
|
|
|
|
|
_haveMark = haveMark;
|
2024-03-14 16:09:51 +04:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_step = _speed / _weight;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) { throw new Exception("Дурашка, какой ноль в весе?"); }
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="speed"></param>
|
|
|
|
|
/// <param name="weight">(0,int.MaxValue]</param>
|
|
|
|
|
/// <param name="firstCol"></param>
|
2024-03-27 13:30:13 +04:00
|
|
|
|
public Liner(int speed, int weight, Color firstCol)
|
2024-03-14 16:09:51 +04:00
|
|
|
|
{
|
|
|
|
|
_speed = speed;
|
|
|
|
|
_weight = weight;
|
|
|
|
|
_firstCol = firstCol;
|
2024-03-27 13:30:13 +04:00
|
|
|
|
_numOfBoxes = 6;
|
2024-03-14 16:09:51 +04:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_step = _speed / _weight;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) { throw e; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|