Добавлены классы для продвинутого объекта;
Необходимо реализовать отрисовку продвинутого ообъекта
This commit is contained in:
parent
0f627662d9
commit
a2b50fbfae
@ -13,9 +13,9 @@ public class DrawingBoat {
|
|||||||
// Координата Y верхнего левого угла лодки
|
// Координата Y верхнего левого угла лодки
|
||||||
private float __startPosY;
|
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;
|
private Integer __pictureWidth = null;
|
||||||
// Высота области отрисовки
|
// Высота области отрисовки
|
||||||
@ -29,6 +29,13 @@ public class DrawingBoat {
|
|||||||
SetPaddlesCount();
|
SetPaddlesCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Инициализатор свойств
|
||||||
|
protected DrawingBoat(int speed, float weight, Color bodyColor, int boatWidth, int boatHeight) {
|
||||||
|
this(speed, weight, bodyColor);
|
||||||
|
__boatWidth = boatWidth;
|
||||||
|
__boatHeight = boatHeight;
|
||||||
|
}
|
||||||
|
|
||||||
// Метод для установки количества весел лодки
|
// Метод для установки количества весел лодки
|
||||||
public void SetPaddlesCount() {
|
public void SetPaddlesCount() {
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
|
23
src/DrawingCatamaran.java
Normal file
23
src/DrawingCatamaran.java
Normal 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
19
src/EntityCatamaran.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user