From 8545247498a2299985533cbdab8377bf2ea4ebea Mon Sep 17 00:00:00 2001 From: crum61kg Date: Sun, 22 Jan 2023 00:55:57 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20(=D0=B1=D0=B5=D0=B7=20TODO)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarmlyShip/WarmlyShip/FormShip.cs | 19 ++++++++++++++++++- .../WarmlyShip/MapWithSetWarmlyShipGeneric.cs | 3 +-- WarmlyShip/WarmlyShip/SetWarmlyShipGeneric.cs | 10 +--------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/WarmlyShip/WarmlyShip/FormShip.cs b/WarmlyShip/WarmlyShip/FormShip.cs index 125d023..5223221 100644 --- a/WarmlyShip/WarmlyShip/FormShip.cs +++ b/WarmlyShip/WarmlyShip/FormShip.cs @@ -54,7 +54,24 @@ namespace WarmlyShip /// private void ButtonMove_Click(object sender, EventArgs e) { - + string name = ((Button)sender)?.Name ?? string.Empty; + switch (name) + { + case "buttonUp": + _ship?.MoveTransport(Direction.Up); + break; + case "buttonDown": + _ship?.MoveTransport(Direction.Down); + break; + case "buttonLeft": + _ship?.MoveTransport(Direction.Left); + break; + case "buttonRight": + _ship?.MoveTransport(Direction.Right); + break; + } + Draw(); + } /// /// Θημενενθε πΰημεπξβ τξπμϋ diff --git a/WarmlyShip/WarmlyShip/MapWithSetWarmlyShipGeneric.cs b/WarmlyShip/WarmlyShip/MapWithSetWarmlyShipGeneric.cs index 56b40bc..9533481 100644 --- a/WarmlyShip/WarmlyShip/MapWithSetWarmlyShipGeneric.cs +++ b/WarmlyShip/WarmlyShip/MapWithSetWarmlyShipGeneric.cs @@ -153,7 +153,7 @@ namespace WarmlyShip for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) { for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j) - {//линия Ρ€Π°ΠΌΠ·Π΅Ρ‚ΠΊΠΈ мСста + { g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2 , j * _placeSizeHeight); } @@ -167,7 +167,6 @@ namespace WarmlyShip /// private void DrawWarmlyShip(Graphics g) { - // TODO установка ΠΏΠΎΠ·ΠΈΡ†ΠΈΠΈ int i = 0; int j = 0; for (int k = 0; k < _setWarmlyShip.Count; k++) diff --git a/WarmlyShip/WarmlyShip/SetWarmlyShipGeneric.cs b/WarmlyShip/WarmlyShip/SetWarmlyShipGeneric.cs index a7edbcd..7f883a3 100644 --- a/WarmlyShip/WarmlyShip/SetWarmlyShipGeneric.cs +++ b/WarmlyShip/WarmlyShip/SetWarmlyShipGeneric.cs @@ -36,7 +36,6 @@ namespace WarmlyShip /// public int Insert(T ship) { - // TODO вставка Π² Π½Π°Ρ‡Π°Π»ΠΎ Π½Π°Π±ΠΎΡ€Π° if (ship == null) { return -1; @@ -56,16 +55,11 @@ namespace WarmlyShip /// public int Insert(T ship, int position) { - // TODO ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ° ΠΏΠΎΠ·ΠΈΡ†ΠΈΠΈ - // TODO ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ°, Ρ‡Ρ‚ΠΎ элСмСнт массива ΠΏΠΎ этой ΠΏΠΎΠ·ΠΈΡ†ΠΈΠΈ пустой, Ссли Π½Π΅Ρ‚, Ρ‚ΠΎ - // ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ°, Ρ‡Ρ‚ΠΎ послС вставляСмого элСмСнта Π² массивС Π΅ΡΡ‚ΡŒ пустой элСмСнт - // сдвиг всСх ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ΠΎΠ², находящихся справа ΠΎΡ‚ ΠΏΠΎΠ·ΠΈΡ†ΠΈΠΈ Π΄ΠΎ ΠΏΠ΅Ρ€Π²ΠΎΠ³ΠΎ пустого элСмСнта - // TODO вставка ΠΏΠΎ ΠΏΠΎΠ·ΠΈΡ†ΠΈΠΈ if (position < 0 || position > Count) { return -1; } - int firstNullElementIndex = position; //индСкс ΠΏΠ΅Ρ€Π²ΠΎΠ³ΠΎ Π½ΡƒΠ»Π΅Π²ΠΎΠ³ΠΎ элСмСнта + int firstNullElementIndex = position; while (_places[firstNullElementIndex] != null) { if (firstNullElementIndex >= Count) @@ -89,8 +83,6 @@ namespace WarmlyShip /// public T Remove(int position) { - // TODO ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ° ΠΏΠΎΠ·ΠΈΡ†ΠΈΠΈ - // TODO ΡƒΠ΄Π°Π»Π΅Π½ΠΈΠ΅ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π° ΠΈΠ· массива, присовив элСмСнту массива Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ null if (_places[position] == null) { return null;