2024-03-14 16:09:51 +04:00

78 lines
2.6 KiB
C#

namespace ProjectAntiAircraftGun
{
public class AntiAircraft : GameObject
{
private int _speed;
private int _weight;
private Color _firstCol;
private Color _secondCol;
private bool _monoChrome;
private int _numOfRollers;
private int _step;
public int Speed { get => _speed;}
public int Weight { get => _weight;}
public Color FirstColor { get => _firstCol; }
public Color SecondColor { get => _secondCol; }
public bool MonoChrome { get => _monoChrome; }
public int NumOfRollers { get => _numOfRollers; }
public int Step { get => _step>0?_step:1; }
public AntiAircraft()
{
_speed = 1;
_weight = 1;
_firstCol = Color.Magenta;
_secondCol = Color.Black;
_monoChrome = true;
_numOfRollers = 6;
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>
/// <param name="numOfRollers">[2,6]</param>
/// <exception cref="Exception"></exception>
public AntiAircraft(int speed, int weight, Color firstCol, Color secondCol, int numOfRollers)
{
if (numOfRollers < 2 || numOfRollers > 6)
throw new Exception("numOfRollers out of range [2,6]");
_speed = speed;
_weight = weight;
_firstCol = firstCol;
_secondCol = secondCol;
_monoChrome = false;
_numOfRollers = numOfRollers;
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>
public AntiAircraft(int speed, int weight, Color firstCol)
{
_speed = speed;
_weight = weight;
_firstCol = firstCol;
_monoChrome = false;
_numOfRollers = 6;
try
{
_step = _speed / _weight;
}
catch (Exception e) { throw e; }
}
}
}