From a2b50fbfae328731f164a3208336a7bacfc1cbe0 Mon Sep 17 00:00:00 2001 From: Nikita Potapov <47923521+nikita-potapov@users.noreply.github.com> Date: Tue, 29 Nov 2022 10:31:01 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D1=8B=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B4=D0=B2=D0=B8=D0=BD=D1=83?= =?UTF-8?q?=D1=82=D0=BE=D0=B3=D0=BE=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82?= =?UTF-8?q?=D0=B0;=20=D0=9D=D0=B5=D0=BE=D0=B1=D1=85=D0=BE=D0=B4=D0=B8?= =?UTF-8?q?=D0=BC=D0=BE=20=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D1=82=D1=8C=20=D0=BE=D1=82=D1=80=D0=B8=D1=81=D0=BE=D0=B2?= =?UTF-8?q?=D0=BA=D1=83=20=D0=BF=D1=80=D0=BE=D0=B4=D0=B2=D0=B8=D0=BD=D1=83?= =?UTF-8?q?=D1=82=D0=BE=D0=B3=D0=BE=20=D0=BE=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA?= =?UTF-8?q?=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/DrawingBoat.java | 11 +++++++++-- src/DrawingCatamaran.java | 23 +++++++++++++++++++++++ src/EntityCatamaran.java | 19 +++++++++++++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 src/DrawingCatamaran.java create mode 100644 src/EntityCatamaran.java diff --git a/src/DrawingBoat.java b/src/DrawingBoat.java index d92a97a..f092340 100644 --- a/src/DrawingBoat.java +++ b/src/DrawingBoat.java @@ -13,9 +13,9 @@ public class DrawingBoat { // Координата Y верхнего левого угла лодки private float __startPosY; // Ширина отрисовки лодки - private final int __boatWidth = 100; + private int __boatWidth = 100; // Высота отрисовки лодки - private final int __boatHeight = 60; + private int __boatHeight = 60; // Ширина области отрисовки private Integer __pictureWidth = null; // Высота области отрисовки @@ -29,6 +29,13 @@ public class DrawingBoat { SetPaddlesCount(); } + // Инициализатор свойств + protected DrawingBoat(int speed, float weight, Color bodyColor, int boatWidth, int boatHeight) { + this(speed, weight, bodyColor); + __boatWidth = boatWidth; + __boatHeight = boatHeight; + } + // Метод для установки количества весел лодки public void SetPaddlesCount() { Random rnd = new Random(); diff --git a/src/DrawingCatamaran.java b/src/DrawingCatamaran.java new file mode 100644 index 0000000..452c716 --- /dev/null +++ b/src/DrawingCatamaran.java @@ -0,0 +1,23 @@ +package src; + +import java.awt.*; + +public class DrawingCatamaran extends DrawingBoat { + public DrawingCatamaran(int speed, float weight, Color bodyColor, Color dopColor, boolean bobbers, boolean sail) { + super(speed, weight, bodyColor, 110, 80); + entityBoat = new EntityCatamaran(speed, weight, bodyColor, dopColor, bobbers, sail); + } + + @Override + public void DrawTransport(Graphics g) { + // Если объект-сущность не того класса - выходим + if (!(entityBoat instanceof EntityCatamaran)) { + return; + } + + // Передаем управление отрисовкой родительскому классу + super.DrawTransport(g); + + // TODO дописать отрисовку поплавков и паруса + } +} diff --git a/src/EntityCatamaran.java b/src/EntityCatamaran.java new file mode 100644 index 0000000..882b085 --- /dev/null +++ b/src/EntityCatamaran.java @@ -0,0 +1,19 @@ +package src; + +import java.awt.*; + +public class EntityCatamaran extends EntityBoat { + // Дополнительный цвет + public Color DopColor; + // Признак наличия поплавков + public boolean Bobbers; + // Признак наличия паруса + public boolean Sail; + + public EntityCatamaran(int speed, float weight, Color bodyColor, Color dopColor, boolean bobbers, boolean sail) { + super(speed, weight, bodyColor); + DopColor = dopColor; + Bobbers = bobbers; + Sail = sail; + } +}