Добавлены классы для продвинутого объекта;

Необходимо реализовать отрисовку продвинутого ообъекта
This commit is contained in:
Nikita Potapov 2022-11-29 10:31:01 +04:00
parent 0f627662d9
commit a2b50fbfae
3 changed files with 51 additions and 2 deletions

View File

@ -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();

23
src/DrawingCatamaran.java Normal file
View File

@ -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 дописать отрисовку поплавков и паруса
}
}

19
src/EntityCatamaran.java Normal file
View File

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