From 5e6e077ef5adad0dec10ea782c2004acd7dacc88 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sat, 22 Oct 2022 21:56:39 +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=D0=B8=D0=B5=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=BE=D0=B2?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B4=D0=B2=D0=B8?= =?UTF-8?q?=D0=BD=D1=83=D1=82=D0=BE=D0=B3=D0=BE=20=D0=BE=D0=B1=D1=8A=D0=B5?= =?UTF-8?q?=D0=BA=D1=82=D0=B0,=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=BE=D0=B4=D0=B8=D1=84=D0=B8=D0=BA?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D1=80=D0=BE=D0=B2=20=D0=BF=D0=BE=D0=BB=D0=B5?= =?UTF-8?q?=D0=B9=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B0=20=D0=B1=D0=B0?= =?UTF-8?q?=D0=B7=D0=BE=D0=B2=D0=BE=D0=B3=D0=BE=20=D0=BE=D0=B1=D1=8A=D0=B5?= =?UTF-8?q?=D0=BA=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/DrawingArmoredCar.java | 8 ++++---- src/main/java/DrawingTank.java | 30 ++++++++++++++++++++++++++++ src/main/java/EntityTank.java | 26 ++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 src/main/java/DrawingTank.java create mode 100644 src/main/java/EntityTank.java diff --git a/src/main/java/DrawingArmoredCar.java b/src/main/java/DrawingArmoredCar.java index 6b0fe3f..005bfc6 100644 --- a/src/main/java/DrawingArmoredCar.java +++ b/src/main/java/DrawingArmoredCar.java @@ -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; diff --git a/src/main/java/DrawingTank.java b/src/main/java/DrawingTank.java new file mode 100644 index 0000000..844548e --- /dev/null +++ b/src/main/java/DrawingTank.java @@ -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; + } +} diff --git a/src/main/java/EntityTank.java b/src/main/java/EntityTank.java new file mode 100644 index 0000000..e8b0211 --- /dev/null +++ b/src/main/java/EntityTank.java @@ -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; + } +}