Добавление классов для продвинутого объекта, изменение модификаторов полей класса базового объекта
This commit is contained in:
parent
4d09e5187d
commit
5e6e077ef5
@ -2,11 +2,11 @@ import java.awt.*;
|
||||
import java.util.Random;
|
||||
|
||||
public class DrawingArmoredCar {
|
||||
private EntityArmoredCar armoredCar;
|
||||
protected EntityArmoredCar armoredCar;
|
||||
|
||||
private float startPosX;
|
||||
protected float startPosX;
|
||||
|
||||
private float startPosY;
|
||||
protected float startPosY;
|
||||
|
||||
private int pictureWidth;
|
||||
|
||||
@ -16,7 +16,7 @@ public class DrawingArmoredCar {
|
||||
|
||||
private int carHeight = 50;
|
||||
|
||||
private DrawingCaterpillar drawingCaterpillar;
|
||||
protected DrawingCaterpillar drawingCaterpillar;
|
||||
|
||||
public EntityArmoredCar getArmoredCar() {
|
||||
return armoredCar;
|
||||
|
30
src/main/java/DrawingTank.java
Normal file
30
src/main/java/DrawingTank.java
Normal file
@ -0,0 +1,30 @@
|
||||
import java.awt.*;
|
||||
|
||||
public class DrawingTank extends DrawingArmoredCar{
|
||||
public DrawingTank(int speed, float weight, Color bodyColor, Color dopColor,
|
||||
boolean towerWeapon, boolean AMachineGun) {
|
||||
super(speed, weight, bodyColor);
|
||||
armoredCar = new EntityTank(speed, weight, bodyColor, dopColor, towerWeapon, AMachineGun);
|
||||
}
|
||||
@Override
|
||||
public void DrawTransport(Graphics2D g) {
|
||||
if (!(armoredCar instanceof EntityTank tank)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tank.isTowerWeapon()) {
|
||||
g.setColor(tank.getDopColor());
|
||||
g.fillRect((int)startPosX + 40, (int)startPosY, 5, 20);
|
||||
g.fillRect((int)startPosX + 40, (int)startPosY, 40, 5);
|
||||
g.fillOval((int)startPosX + 27, (int)startPosY + 7, 30, 10);
|
||||
}
|
||||
if (tank.isAMachineGun()) {
|
||||
g.setColor(tank.getDopColor());
|
||||
g.fillRect((int)startPosX + 60, (int)startPosY + 15, 7, 10);
|
||||
g.fillRect((int)startPosX + 60, (int)startPosY + 17, 20, 5);
|
||||
}
|
||||
startPosY += 10;
|
||||
super.DrawTransport(g);
|
||||
startPosY -= 10;
|
||||
}
|
||||
}
|
26
src/main/java/EntityTank.java
Normal file
26
src/main/java/EntityTank.java
Normal file
@ -0,0 +1,26 @@
|
||||
import java.awt.*;
|
||||
|
||||
public class EntityTank extends EntityArmoredCar{
|
||||
private Color dopColor;
|
||||
private boolean towerWeapon;
|
||||
private boolean AMachineGun;
|
||||
|
||||
public Color getDopColor() {
|
||||
return dopColor;
|
||||
}
|
||||
|
||||
public boolean isTowerWeapon() {
|
||||
return towerWeapon;
|
||||
}
|
||||
|
||||
public boolean isAMachineGun() {
|
||||
return AMachineGun;
|
||||
}
|
||||
|
||||
public EntityTank(int speed, float weight, Color bodyColor, Color dopColor, boolean towerWeapon, boolean AMachineGun) {
|
||||
super(speed, weight, bodyColor);
|
||||
this.dopColor = dopColor;
|
||||
this.towerWeapon = towerWeapon;
|
||||
this.AMachineGun = AMachineGun;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user