diff --git a/Warship/Warship/Direction.cs b/Warship/Warship/Direction.cs index 8467015..ef6925d 100644 --- a/Warship/Warship/Direction.cs +++ b/Warship/Warship/Direction.cs @@ -11,6 +11,6 @@ namespace Warship Up=1, Down=2, Left=3, - Right=4 + Right=4, } } diff --git a/Warship/Warship/DrawingWarship.cs b/Warship/Warship/DrawingWarship.cs index 76a3574..0fcbba0 100644 --- a/Warship/Warship/DrawingWarship.cs +++ b/Warship/Warship/DrawingWarship.cs @@ -16,10 +16,9 @@ namespace Warship private readonly int _warshipWidth = 120; private readonly int _warshipHeight = 40; - public void Init(int speed, float weight,Color bodyColor) + public DrawingWarship(int speed, float weight,Color bodyColor) { - Warship = new EntityWarship(); - Warship.Init(speed, weight, bodyColor); + Warship = new EntityWarship(speed, weight, bodyColor); } public void SetPosition(int x, int y, int width, int height) diff --git a/Warship/Warship/EntityWarship.cs b/Warship/Warship/EntityWarship.cs index b151cd6..288a008 100644 --- a/Warship/Warship/EntityWarship.cs +++ b/Warship/Warship/EntityWarship.cs @@ -13,7 +13,7 @@ namespace Warship public Color BodyColor { get; private set; } public int Step => (int)(Speed * 2000 / Weight); - public void Init(int speed, float weight, Color bodyColor) + public EntityWarship(int speed, float weight, Color bodyColor) { Random rnd = new(); Speed = speed <= 0 ? rnd.Next(10, 60) : speed; diff --git a/Warship/Warship/FormWarship.cs b/Warship/Warship/FormWarship.cs index 2eb6e56..f99c694 100644 --- a/Warship/Warship/FormWarship.cs +++ b/Warship/Warship/FormWarship.cs @@ -18,8 +18,7 @@ namespace Warship private void buttonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - _warship = new DrawingWarship(); - _warship.Init(rnd.Next(10, 60), rnd.Next(20000, 25000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + _warship = new DrawingWarship(rnd.Next(10, 60), rnd.Next(20000, 25000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); _warship.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxWarship.Width, pictureBoxWarship.Height); toolStripStatusLabelSpeed.Text = $"Cкорость: {_warship.Warship.Speed}"; toolStripStatusLabelWeight.Text = $"Вес: {_warship.Warship.Weight}";