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; + } +}