From 880d59a6e62d83cc61e90f9f51f11017d8e8c54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=B9=D0=B4=D0=B0=D1=80?= Date: Mon, 3 Oct 2022 19:11:11 +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 --- Battleship/Battleship/DrawningBattleship.cs | 5 ++--- Battleship/Battleship/EntityBattleship.cs | 2 +- Battleship/Battleship/FormBattleship.cs | 3 +-- Battleship/Battleship/FormBattleship.resx | 3 +++ 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Battleship/Battleship/DrawningBattleship.cs b/Battleship/Battleship/DrawningBattleship.cs index 2217080..4095cc7 100644 --- a/Battleship/Battleship/DrawningBattleship.cs +++ b/Battleship/Battleship/DrawningBattleship.cs @@ -45,10 +45,9 @@ namespace Battleship /// Скорость /// Вес боевого корабля /// Цвет корпуса - public void Init(int speed, float weight, Color bodyColor) + public DrawningBattleship(int speed, float weight, Color bodyColor) { - Battleship = new EntityBattleship(); - Battleship.Init(speed, weight, bodyColor); + Battleship = new EntityBattleship(speed, weight, bodyColor); } /// /// Установка позиции боевого корабля diff --git a/Battleship/Battleship/EntityBattleship.cs b/Battleship/Battleship/EntityBattleship.cs index ddcb788..00a13de 100644 --- a/Battleship/Battleship/EntityBattleship.cs +++ b/Battleship/Battleship/EntityBattleship.cs @@ -34,7 +34,7 @@ namespace Battleship /// /// /// - public void Init(int speed, float weight, Color bodyColor) + public EntityBattleship(int speed, float weight, Color bodyColor) { Random rnd = new(); Speed = speed <= 0 ? rnd.Next(50, 150) : speed; diff --git a/Battleship/Battleship/FormBattleship.cs b/Battleship/Battleship/FormBattleship.cs index 00d8b54..7d4e6bc 100644 --- a/Battleship/Battleship/FormBattleship.cs +++ b/Battleship/Battleship/FormBattleship.cs @@ -28,8 +28,7 @@ namespace Battleship private void ButtonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - _battleship = new DrawningBattleship(); - _battleship.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + _battleship = new DrawningBattleship(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); _battleship.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxBattleship.Width, pictureBoxBattleship.Height); toolStripStatusLabelSpeed.Text = $": {_battleship.Battleship.Speed}"; toolStripStatusLabelWeight.Text = $": {_battleship.Battleship.Weight}"; diff --git a/Battleship/Battleship/FormBattleship.resx b/Battleship/Battleship/FormBattleship.resx index dd36fec..8cfaecb 100644 --- a/Battleship/Battleship/FormBattleship.resx +++ b/Battleship/Battleship/FormBattleship.resx @@ -60,4 +60,7 @@ 17, 17 + + 25 + \ No newline at end of file