From ac9d6db704630075751e78705176ec678c476076 Mon Sep 17 00:00:00 2001 From: Danila_Mochalov Date: Tue, 27 Sep 2022 16:26:05 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B0=D0=BD=D0=BD=D0=B0=D1=8F=20?= =?UTF-8?q?=D1=81=D0=BB=D0=BE=D0=B6=D0=BD=D0=B0=D1=8F=20=D0=BB=D0=B0=D0=B1?= =?UTF-8?q?=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrawningLocomotive.java | 7 ++++--- ExtraWheelsDraw.java | 29 ++++++++++++----------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/DrawningLocomotive.java b/DrawningLocomotive.java index c39e0e1..7baf701 100644 --- a/DrawningLocomotive.java +++ b/DrawningLocomotive.java @@ -12,14 +12,15 @@ class DrawningLocomotive { /// Высота окна отрисовки private Integer _pictureHeight = null; /// Ширина отрисовки локомотива - private final int _locomotiveWidth = 110; + private final int _locomotiveWidth = 120; /// Высота отрисовки локомотива private final int _locomotiveHeight = 50; /// Инициализация свойств public void Init(int speed, float weight, Color bodyColor, int wheelsNum, EntityLocomotive entity) { Locomotive = entity; - extraWheelsDraw = new ExtraWheelsDraw(wheelsNum, bodyColor); + extraWheelsDraw = new ExtraWheelsDraw(); + extraWheelsDraw.Init(wheelsNum, bodyColor); Locomotive.Init(speed, weight, bodyColor); } /// Установка позиции локомотива @@ -90,7 +91,7 @@ class DrawningLocomotive { } //тело g.setColor(Color.BLACK); - g.drawRect((int)_startPosX , (int)_startPosY, _locomotiveWidth - 10, _locomotiveHeight - 10); + g.drawRect((int)_startPosX , (int)_startPosY, _locomotiveWidth - 20, _locomotiveHeight - 10); //окна g.setColor(Locomotive.getBodyColor()); g.fillRect((int)_startPosX + 10, (int)_startPosY + 10, 10, 10); diff --git a/ExtraWheelsDraw.java b/ExtraWheelsDraw.java index 3bad278..4a19792 100644 --- a/ExtraWheelsDraw.java +++ b/ExtraWheelsDraw.java @@ -1,28 +1,24 @@ import java.awt.*; public class ExtraWheelsDraw { - private WheelsCount wheelsCount; - private int wheelsNum; + private WheelsCount wheelsCount = WheelsCount.Two; public void setWheelsNum(int num) { - wheelsNum = num; - switch (wheelsNum) { + switch (num) { case 0: { - wheelsCount = WheelsCount.Two; - break; - } - case 1: { wheelsCount = WheelsCount.Three; break; } - case 2: { + case 1: { wheelsCount = WheelsCount.Four; break; } + default: + break; } } - private final Color color; + private Color color; - public ExtraWheelsDraw(int num, Color color) { + public void Init(int num, Color color) { setWheelsNum(num); this.color = color; } @@ -32,17 +28,16 @@ public class ExtraWheelsDraw { g.drawOval(startPosX, startPosY + 40, 10, 10); g.drawOval(startPosX + 90, startPosY + 40, 10, 10); switch (wheelsCount) { - case Two: { - break; + case Four: { + g.drawOval(startPosX + 70, startPosY + 40, 10, 10); } case Three: { g.drawOval(startPosX + 20, startPosY + 40, 10, 10); break; } - case Four: { - g.drawOval(startPosX + 20, startPosY + 40, 10, 10); - g.drawOval(startPosX + 70, startPosY + 40, 10, 10); - } + default: + break; } } + }