Переход на конструкторы
This commit is contained in:
parent
7865c256dc
commit
59f5022d99
@ -12,10 +12,9 @@
|
||||
private int? _pictureHeight = null;
|
||||
private readonly int _shipWidth = 80;
|
||||
private readonly int _shipHeight = 50;
|
||||
public void Init(int speed, float weight, Color сolor)
|
||||
public DrawningShip(int speed, float weight, Color сolor)
|
||||
{
|
||||
Ship = new EntityShip();
|
||||
Ship.Init(speed, weight, сolor);
|
||||
Ship = new EntityShip(speed, weight, сolor);
|
||||
}
|
||||
public void SetPosition(int x, int y, int width, int height)
|
||||
{
|
||||
|
@ -19,7 +19,7 @@
|
||||
/// </summary>
|
||||
public float Step => Speed * 100 / Weight;
|
||||
|
||||
public void Init(int speed, float weight, Color сolor)
|
||||
public EntityShip(int speed, float weight, Color сolor)
|
||||
{
|
||||
Random rnd = new();
|
||||
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
||||
|
@ -17,8 +17,7 @@ namespace WarmlyShip
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_ship = new DrawningShip();
|
||||
_ship.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
_ship = new DrawningShip(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
_ship.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxShip.Width, pictureBoxShip.Height);
|
||||
toolStripStatusSpeed.Text = $"Ñêîðîñòü: {_ship.Ship.Speed}";
|
||||
toolStripStatusWeight.Text = $"Âåñ: {_ship.Ship.Weight}";
|
||||
|
Loading…
x
Reference in New Issue
Block a user