From cd528db9c67e5eef874c09f50e1c884a922752bb Mon Sep 17 00:00:00 2001 From: AnnZhimol Date: Tue, 20 Sep 2022 18:32:27 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D1=85=D0=BE=D0=B4=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BA=D0=BE=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BA?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Warship/Warship/Direction.cs | 2 +- Warship/Warship/DrawingWarship.cs | 5 ++--- Warship/Warship/EntityWarship.cs | 2 +- Warship/Warship/FormWarship.cs | 3 +-- 4 files changed, 5 insertions(+), 7 deletions(-) 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}";