Переход на конструкторы
This commit is contained in:
parent
0002354055
commit
fc67dec55e
@ -45,10 +45,9 @@ namespace WarmlyShip
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес корабля</param>
|
||||
/// <param name="bodyColor">Цвет палубы</param>
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
public DrawningShip(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Ship = new EntityShip();
|
||||
Ship.Init(speed, weight, bodyColor);
|
||||
Ship = new EntityShip(speed, weight, bodyColor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -35,7 +35,7 @@ namespace WarmlyShip
|
||||
/// <param name="weight"></param>
|
||||
/// <param name="bodyColor"></param>
|
||||
/// <returns></returns>
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
public EntityShip(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Random rnd = new();
|
||||
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
||||
|
@ -28,8 +28,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);
|
||||
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_ship.Ship.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Âåñ: {_ship.Ship.Weight}";
|
||||
|
Loading…
Reference in New Issue
Block a user