From e822561eec5d0b24245829a5ff267c6002484aa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=20=D0=91=D0=BE=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Tue, 29 Nov 2022 22:21:03 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrawDeck.java | 21 +++++++++------------ DrawingShip.java | 1 - 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/DrawDeck.java b/DrawDeck.java index 32d29c7..6cddc71 100644 --- a/DrawDeck.java +++ b/DrawDeck.java @@ -10,26 +10,23 @@ public class DrawDeck implements IDrawningDeck { @Override public void DrawningDeck(float _startPosX, float _startPosY, int _warmlyShipWidth, Graphics2D g2d, Color bodyColor){ + int count = 1; switch (deckCount) { case One: break; - case Two: - g2d.setColor(bodyColor); - g2d.fillRect((int)(_startPosX + _warmlyShipWidth / 5), (int)_startPosY - 20, _warmlyShipWidth * 3 / 5, 20); - g2d.setColor(Color.BLACK); - g2d.drawRect((int)(_startPosX + _warmlyShipWidth / 5), (int)_startPosY - 20, _warmlyShipWidth * 3 / 5, 20); + count = 2; break; - case Three: - for (int i = 1; i < 3; ++i){ - g2d.setColor(bodyColor); - g2d.fillRect((int)(_startPosX + _warmlyShipWidth / 5), (int)_startPosY - 20 * i, _warmlyShipWidth * 3 / 5, 20); - g2d.setColor(Color.BLACK); - g2d.drawRect((int)(_startPosX + _warmlyShipWidth / 5), (int)_startPosY - 20 * i, _warmlyShipWidth * 3 / 5, 20); - } + count = 3; break; } + for (int i = 1; i < count; ++i){ + g2d.setColor(bodyColor); + g2d.fillRect((int)(_startPosX + _warmlyShipWidth / 5), (int)_startPosY - 20 * i, _warmlyShipWidth * 3 / 5, 20); + g2d.setColor(Color.BLACK); + g2d.drawRect((int)(_startPosX + _warmlyShipWidth / 5), (int)_startPosY - 20 * i, _warmlyShipWidth * 3 / 5, 20); + } } } diff --git a/DrawingShip.java b/DrawingShip.java index 6b2bc10..442df41 100644 --- a/DrawingShip.java +++ b/DrawingShip.java @@ -12,7 +12,6 @@ public class DrawingShip extends JPanel { protected int _warmlyShipWidth = 125; //Ширина отрисовки корабля protected int _warmlyShipHeight = 50; //Высота отрисовки корабля - private int deckCount = 1; private IDrawningDeck idd; //Инициализация