From 8be5839af019467c203b9b4850170d48d34c65f6 Mon Sep 17 00:00:00 2001 From: DyCTaTOR <125912249+DyCTaTOR@users.noreply.github.com> Date: Wed, 6 Dec 2023 10:09:34 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BD=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrawingWheels.java | 9 ++------- DrawningMonorail.java | 13 ++++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/DrawingWheels.java b/DrawingWheels.java index 90e8fe9..a10f3fb 100644 --- a/DrawingWheels.java +++ b/DrawingWheels.java @@ -1,8 +1,6 @@ import java.awt.Color; import java.awt.Graphics; public class DrawingWheels{ - private int _startPosX; - private int _startPosY; Graphics g; Color color; private CountWheels _countWheels; @@ -16,14 +14,11 @@ public class DrawingWheels{ _countWheels = CountWheels.fromNumberToEnum(numRollers); } - public DrawingWheels(Graphics g, int startPosX, int startPosY, Color color, int countWheels){ - this.g = g; - _startPosX = startPosX; - _startPosY = startPosY; + public DrawingWheels(Color color, int countWheels){ this.color = color; setNumWheels(countWheels); } - public void Draw(){ + public void Draw(Graphics g, int _startPosX, int _startPosY){ switch(_countWheels){ case Min: g.setColor(Color.BLACK); diff --git a/DrawningMonorail.java b/DrawningMonorail.java index 427ff68..e28c08b 100644 --- a/DrawningMonorail.java +++ b/DrawningMonorail.java @@ -13,7 +13,7 @@ public class DrawningMonorail extends JPanel { private int relWidth = 150; private final int relHeight = 46; Random rd = new Random(); - public DrawningMonorail(){} + private DrawingWheels _drawingWheels; public boolean init(int wheelCount ,int speed, double weight, Color bodyColor, Color additionalColor, boolean monorails, boolean secondCabin, int width, int height) { @@ -25,6 +25,7 @@ public class DrawningMonorail extends JPanel { pictureHeight = height; entity = new Entity(); entity.init(wheelCount, speed, weight, bodyColor, additionalColor, monorails, secondCabin); + _drawingWheels = new DrawingWheels(entity.getBodyColor(), _countWheels); return true; } @@ -77,9 +78,7 @@ public class DrawningMonorail extends JPanel { g.fillRect(_startPosX + 82, _startPosY + 36, 40, 8); g.fillOval( _startPosX + 3, _startPosY + 37, 30, 8); g.fillOval( _startPosX + 110, _startPosY + 37, 29, 8); - DrawingWheels _drawingWheels = new DrawingWheels(g, _startPosX, _startPosY, - entity.getBodyColor(), _countWheels); - _drawingWheels.Draw(); + _drawingWheels.Draw(g, _startPosX, _startPosY); //Кабина g.setColor(entity.getBodyColor()); @@ -139,9 +138,9 @@ public class DrawningMonorail extends JPanel { g.fillOval(_startPosX + 143, _startPosY + 37, 30, 8); g.fillOval(_startPosX + 250, _startPosY + 37, 29, 8); - _drawingWheels = new DrawingWheels(g, _startPosX + 140, _startPosY, - entity.getAdditionalColor(), _countWheels); - _drawingWheels.Draw(); + //_drawingWheels = new DrawingWheels(g, _startPosX + 140, _startPosY, + //entity.getAdditionalColor(), _countWheels); + _drawingWheels.Draw(g, _startPosX + 140, _startPosY); if (entity.getMonorails()) { g.setColor(Color.BLACK);