From 18a72916b66e845f9545716cf50bb50e271a46f5 Mon Sep 17 00:00:00 2001 From: Danila_Mochalov Date: Sat, 8 Oct 2022 22:13:56 +0400 Subject: [PATCH] Added IDrawningExtra, ExtraWheelsDraw implements IDrawningExtra --- DrawningLocomotive.java | 2 +- DrawningWarmlyLocomotive.java | 2 +- ExtraWheelsDraw.java | 8 ++++---- IDrawningExtra.java | 6 ++++++ 4 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 IDrawningExtra.java diff --git a/DrawningLocomotive.java b/DrawningLocomotive.java index bc3cbef..ae45dbd 100644 --- a/DrawningLocomotive.java +++ b/DrawningLocomotive.java @@ -110,7 +110,7 @@ class DrawningLocomotive { g.setColor(Color.BLACK); g.drawRect( (int)_startPosX + 50, (int)_startPosY + 10, 10, 20); //колеса - extraWheelsDraw.DrawWheels((int)_startPosX, (int)_startPosY, g); + extraWheelsDraw.DrawExtra((int)_startPosX, (int)_startPosY, g); //движок g.setColor(Locomotive.getBodyColor()); g.fillRect((int)_startPosX + 100, (int)_startPosY + 10, 10, 30); diff --git a/DrawningWarmlyLocomotive.java b/DrawningWarmlyLocomotive.java index bc5cc09..f7fd094 100644 --- a/DrawningWarmlyLocomotive.java +++ b/DrawningWarmlyLocomotive.java @@ -23,7 +23,7 @@ public class DrawningWarmlyLocomotive extends DrawningLocomotive{ if (warmlyLocomotive.FuelStorage) { - g.fillRect((int)_startPosX + 110, (int)_startPosY + 10, 10, 50); + g.fillRect((int)_startPosX + 120, (int)_startPosY + 10, 10, 50); g.fillRect((int)_startPosX + 110, (int)_startPosY + 40, 20, 20); g.fillRect((int)_startPosX + 110, (int)_startPosY, 30, 10); } diff --git a/ExtraWheelsDraw.java b/ExtraWheelsDraw.java index 551b428..abe9d15 100644 --- a/ExtraWheelsDraw.java +++ b/ExtraWheelsDraw.java @@ -1,8 +1,8 @@ import java.awt.*; -public class ExtraWheelsDraw { +public class ExtraWheelsDraw implements IDrawningExtra{ private WheelsCount wheelsCount = WheelsCount.Two; - public void setWheelsNum(int num) { + public void setExtraNum(int num) { switch (num) { case 0: { wheelsCount = WheelsCount.Three; @@ -19,11 +19,11 @@ public class ExtraWheelsDraw { private Color color; public ExtraWheelsDraw(int num, Color color) { - setWheelsNum(num); + setExtraNum(num); this.color = color; } - public void DrawWheels(int startPosX, int startPosY, Graphics2D g) { + public void DrawExtra(int startPosX, int startPosY, Graphics2D g) { g.setColor(color); g.drawOval(startPosX, startPosY + 40, 10, 10); g.drawOval(startPosX + 90, startPosY + 40, 10, 10); diff --git a/IDrawningExtra.java b/IDrawningExtra.java new file mode 100644 index 0000000..725e87a --- /dev/null +++ b/IDrawningExtra.java @@ -0,0 +1,6 @@ +import java.awt.*; + +public interface IDrawningExtra { + void setExtraNum(int num); + void DrawExtra(int startPosX, int startPosY, Graphics2D g); +}