From 202784cb0a6883ebbbc0d52230dc4edae0dfacbc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=92=D0=B8=D0=BA=D1=82=D0=BE=D1=80=D0=B8=D1=8F=20=D0=9A?=
=?UTF-8?q?=D1=83=D0=B4=D1=8F=D0=B5=D0=B2=D0=B0?=
<147080087+TUSHKANCH11K@users.noreply.github.com>
Date: Sun, 9 Jun 2024 04:06:18 +0400
Subject: [PATCH] labWork01
---
SelfPropelledArtilleryUnit_Hard/.gitignore | 29 +++
.../.idea/.gitignore | 3 +
.../.idea/misc.xml | 6 +
.../.idea/modules.xml | 8 +
.../.idea/uiDesigner.xml | 124 ++++++++++++
.../Resources/30px_arrow_down.png | Bin 0 -> 244 bytes
.../Resources/30px_arrow_left.png | Bin 0 -> 249 bytes
.../Resources/30px_arrow_right.png | Bin 0 -> 254 bytes
.../Resources/30px_arrow_up.png | Bin 0 -> 257 bytes
.../SelfPropelledArtilleryUnit_Hard.iml | 12 ++
.../src/CrawlerRollersCount.java | 14 ++
.../src/DirectionType.java | 6 +
.../src/DrawingCrawlerRollers.java | 24 +++
.../DrawingSelfPropelledArtilleryUnit.java | 183 ++++++++++++++++++
.../src/EntitySelfPropelledArtilleryUnit.java | 48 +++++
.../src/FormSelfPropelledArtilleryUnit.form | 93 +++++++++
.../src/FormSelfPropelledArtilleryUnit.java | 107 ++++++++++
SelfPropelledArtilleryUnit_Hard/src/Main.java | 14 ++
18 files changed, 671 insertions(+)
create mode 100644 SelfPropelledArtilleryUnit_Hard/.gitignore
create mode 100644 SelfPropelledArtilleryUnit_Hard/.idea/.gitignore
create mode 100644 SelfPropelledArtilleryUnit_Hard/.idea/misc.xml
create mode 100644 SelfPropelledArtilleryUnit_Hard/.idea/modules.xml
create mode 100644 SelfPropelledArtilleryUnit_Hard/.idea/uiDesigner.xml
create mode 100644 SelfPropelledArtilleryUnit_Hard/Resources/30px_arrow_down.png
create mode 100644 SelfPropelledArtilleryUnit_Hard/Resources/30px_arrow_left.png
create mode 100644 SelfPropelledArtilleryUnit_Hard/Resources/30px_arrow_right.png
create mode 100644 SelfPropelledArtilleryUnit_Hard/Resources/30px_arrow_up.png
create mode 100644 SelfPropelledArtilleryUnit_Hard/SelfPropelledArtilleryUnit_Hard.iml
create mode 100644 SelfPropelledArtilleryUnit_Hard/src/CrawlerRollersCount.java
create mode 100644 SelfPropelledArtilleryUnit_Hard/src/DirectionType.java
create mode 100644 SelfPropelledArtilleryUnit_Hard/src/DrawingCrawlerRollers.java
create mode 100644 SelfPropelledArtilleryUnit_Hard/src/DrawingSelfPropelledArtilleryUnit.java
create mode 100644 SelfPropelledArtilleryUnit_Hard/src/EntitySelfPropelledArtilleryUnit.java
create mode 100644 SelfPropelledArtilleryUnit_Hard/src/FormSelfPropelledArtilleryUnit.form
create mode 100644 SelfPropelledArtilleryUnit_Hard/src/FormSelfPropelledArtilleryUnit.java
create mode 100644 SelfPropelledArtilleryUnit_Hard/src/Main.java
diff --git a/SelfPropelledArtilleryUnit_Hard/.gitignore b/SelfPropelledArtilleryUnit_Hard/.gitignore
new file mode 100644
index 0000000..f68d109
--- /dev/null
+++ b/SelfPropelledArtilleryUnit_Hard/.gitignore
@@ -0,0 +1,29 @@
+### IntelliJ IDEA ###
+out/
+!**/src/main/**/out/
+!**/src/test/**/out/
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+bin/
+!**/src/main/**/bin/
+!**/src/test/**/bin/
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/SelfPropelledArtilleryUnit_Hard/.idea/.gitignore b/SelfPropelledArtilleryUnit_Hard/.idea/.gitignore
new file mode 100644
index 0000000..eaf91e2
--- /dev/null
+++ b/SelfPropelledArtilleryUnit_Hard/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/SelfPropelledArtilleryUnit_Hard/.idea/misc.xml b/SelfPropelledArtilleryUnit_Hard/.idea/misc.xml
new file mode 100644
index 0000000..90ca720
--- /dev/null
+++ b/SelfPropelledArtilleryUnit_Hard/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SelfPropelledArtilleryUnit_Hard/.idea/modules.xml b/SelfPropelledArtilleryUnit_Hard/.idea/modules.xml
new file mode 100644
index 0000000..c66a155
--- /dev/null
+++ b/SelfPropelledArtilleryUnit_Hard/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SelfPropelledArtilleryUnit_Hard/.idea/uiDesigner.xml b/SelfPropelledArtilleryUnit_Hard/.idea/uiDesigner.xml
new file mode 100644
index 0000000..6d50cd4
--- /dev/null
+++ b/SelfPropelledArtilleryUnit_Hard/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/SelfPropelledArtilleryUnit_Hard/Resources/30px_arrow_down.png b/SelfPropelledArtilleryUnit_Hard/Resources/30px_arrow_down.png
new file mode 100644
index 0000000000000000000000000000000000000000..7aa32554361c5096853e1a67276f0da08b666977
GIT binary patch
literal 244
zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1SGcvS$+jloCO|{#S9EWB_ParFHODzD7ehi
z#WBRA^X*kbp=JXf7Kd0h`vptS{Ev6>oNcbb%E+|MPpGHcASSz#`|J;%(5YsXCPlX|
z`4_P%I7MiuZt2+bTU`Fdv4d8>&d1*W;u}9PPQGe`;i)O&%fk-l?_?tRPSx1g-h*@y$HPFQjp00i_>zopr0ChuOg8%>k
literal 0
HcmV?d00001
diff --git a/SelfPropelledArtilleryUnit_Hard/Resources/30px_arrow_left.png b/SelfPropelledArtilleryUnit_Hard/Resources/30px_arrow_left.png
new file mode 100644
index 0000000000000000000000000000000000000000..9a3dfa2d5b89d36919b575b8befd59eac504d75e
GIT binary patch
literal 249
zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1SGcvS$+jloCO|{#S9EWB_ParFHODzD7f0w
z#WBRA^X#>QybT5%tN{jj53Vl$?f>NBYU3JyHPf{jOaH1E9mr;8UB#fH)~4{?e9Nk~
z3vu7I*RJ}#=fg|0?SAIFMRy$+op|wSoo3oAN7LOKf9|`yP3?k*N4i|l6qD1snTuv$
zjQPIkG?%%2RWks*vIi`7u`I25Nb!YfkCWjxp-pybJbT)&htDnm{r-UW|LqcYO
literal 0
HcmV?d00001
diff --git a/SelfPropelledArtilleryUnit_Hard/Resources/30px_arrow_right.png b/SelfPropelledArtilleryUnit_Hard/Resources/30px_arrow_right.png
new file mode 100644
index 0000000000000000000000000000000000000000..0f06fd0640536a7d699730ab5c192deace71668e
GIT binary patch
literal 254
zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1SGcvS$+jloCO|{#S9EWB_ParFHODzD7eAX
z#WBRA^XxT4z6Jvh)_|-%jjI=bx1YFpb^3~CPt}aK?DfJkWxjYWSfKe_r#9)ulU*;T
z1nJ*ey8C5qoP%vpb^!l2!HbX8m#pl6dg^NJ+Ush`CfkKd51qK8b$I46_qk>-%IEHM
z?(vKBk5a#UdE2zhhn8$Ty`DMcsJ{i>))#S@ZE}gjVI~7y13T$wCnDw
z&$r3~qp!cW(aU;qs`b8Ww3U7Dt`)1|``+zbapnATLGje8$_2ra-H>*
zUI~?GXQRn!Gfhq}iHuuhtC_8P?QX(9kLP=sy=Fd8(=v6@0lJXE)78&qol`;+0Nwv%
AVgLXD
literal 0
HcmV?d00001
diff --git a/SelfPropelledArtilleryUnit_Hard/SelfPropelledArtilleryUnit_Hard.iml b/SelfPropelledArtilleryUnit_Hard/SelfPropelledArtilleryUnit_Hard.iml
new file mode 100644
index 0000000..ceb0789
--- /dev/null
+++ b/SelfPropelledArtilleryUnit_Hard/SelfPropelledArtilleryUnit_Hard.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SelfPropelledArtilleryUnit_Hard/src/CrawlerRollersCount.java b/SelfPropelledArtilleryUnit_Hard/src/CrawlerRollersCount.java
new file mode 100644
index 0000000..d016394
--- /dev/null
+++ b/SelfPropelledArtilleryUnit_Hard/src/CrawlerRollersCount.java
@@ -0,0 +1,14 @@
+public enum CrawlerRollersCount {
+ Four(4),
+ Five(5),
+ Six(6);
+
+ private int numOfRollers;
+ CrawlerRollersCount(int numOfRollers){
+ this.numOfRollers = numOfRollers;
+ }
+ public int getNumOfRollers(){
+ return numOfRollers;
+ }
+}
+
diff --git a/SelfPropelledArtilleryUnit_Hard/src/DirectionType.java b/SelfPropelledArtilleryUnit_Hard/src/DirectionType.java
new file mode 100644
index 0000000..913ef3f
--- /dev/null
+++ b/SelfPropelledArtilleryUnit_Hard/src/DirectionType.java
@@ -0,0 +1,6 @@
+public enum DirectionType {
+ Up,
+ Down,
+ Left,
+ Right
+}
\ No newline at end of file
diff --git a/SelfPropelledArtilleryUnit_Hard/src/DrawingCrawlerRollers.java b/SelfPropelledArtilleryUnit_Hard/src/DrawingCrawlerRollers.java
new file mode 100644
index 0000000..e5867df
--- /dev/null
+++ b/SelfPropelledArtilleryUnit_Hard/src/DrawingCrawlerRollers.java
@@ -0,0 +1,24 @@
+import java.awt.*;
+
+public class DrawingCrawlerRollers {
+ private CrawlerRollersCount rollersCount;
+ public void setCrawlerRollersCount(int numOfRoller){
+ for (CrawlerRollersCount numofenum : CrawlerRollersCount.values()){
+ if (numofenum.getNumOfRollers() == numOfRoller){
+ rollersCount = numofenum;
+ return;
+ }
+ }
+ }
+
+ public CrawlerRollersCount getCrawlerRollersCount(){
+ return rollersCount;
+ }
+ public void DrawRollers(Graphics g, int x, int y, int width, int height, Color bodyColor){
+ g.setColor(bodyColor);
+ g.fillOval(x, y, width, height);
+ g.setColor(Color.BLACK);
+ g.drawOval(x, y, width, height);
+ g.setColor(bodyColor);
+ }
+}
diff --git a/SelfPropelledArtilleryUnit_Hard/src/DrawingSelfPropelledArtilleryUnit.java b/SelfPropelledArtilleryUnit_Hard/src/DrawingSelfPropelledArtilleryUnit.java
new file mode 100644
index 0000000..56992a3
--- /dev/null
+++ b/SelfPropelledArtilleryUnit_Hard/src/DrawingSelfPropelledArtilleryUnit.java
@@ -0,0 +1,183 @@
+import java.awt.*;
+import java.util.Random;
+
+public class DrawingSelfPropelledArtilleryUnit {
+ private EntitySelfPropelledArtilleryUnit entitySelfPropelledArtilleryUnit;
+ public DrawingCrawlerRollers drawingCrawlerRollers = null;
+ private Integer pictureWidth;
+ private Integer pictureHeight;
+ private Integer _startPosX;
+ private Integer _startPosY;
+ private final int drawingSelfPropelledArtilleryUnitWidth = 100;
+ private final int drawingSelfPropelledArtilleryUnitHeight = 50;
+ private final int drawingKeelHeight = 35;
+ private DrawingCrawlerRollers _drawingCrawlerRollers;
+ public EntitySelfPropelledArtilleryUnit EntitySelfPropelledArtilleryUnit() {
+ return entitySelfPropelledArtilleryUnit;
+ }
+ public void Init(int speed, double weight, Color bodyColor, Color additionalColor, boolean turretCannon, boolean launchBattery) {
+ entitySelfPropelledArtilleryUnit = new EntitySelfPropelledArtilleryUnit();
+ entitySelfPropelledArtilleryUnit.Init(speed, weight, bodyColor, additionalColor, turretCannon, launchBattery);
+ pictureHeight = null;
+ pictureWidth = null;
+ _startPosX = null;
+ _startPosY = null;
+ drawingCrawlerRollers = new DrawingCrawlerRollers();
+ Random random = new Random();
+ int rand = random.nextInt(3,7);
+ drawingCrawlerRollers.setCrawlerRollersCount(rand);
+ }
+
+ public void setPictureSize(int width, int height) {
+ pictureWidth = width;
+ pictureHeight = height;
+ }
+
+ public void setPosition(int x, int y) {
+ if (pictureHeight == null || pictureWidth == null) {
+ return;
+ }
+
+ if (x < 0) {
+ x = 0;
+ } else if (x - drawingSelfPropelledArtilleryUnitWidth >= pictureWidth) {
+ x = pictureWidth - drawingSelfPropelledArtilleryUnitWidth - drawingSelfPropelledArtilleryUnitWidth;
+ }
+
+ if (y - drawingKeelHeight < 0) {
+ y = drawingKeelHeight;
+ } else if (y - drawingSelfPropelledArtilleryUnitHeight >= pictureHeight) {
+ y = pictureHeight - drawingSelfPropelledArtilleryUnitHeight - drawingSelfPropelledArtilleryUnitHeight;
+ }
+
+ _startPosY = y;
+ _startPosX = x;
+ }
+
+ public boolean moveTransport(DirectionType direction) {
+ if (entitySelfPropelledArtilleryUnit == null || _startPosX == null || _startPosY == null || pictureWidth == null || pictureHeight == null) {
+ return false;
+ }
+
+ return switch (direction) {
+ case Left -> {
+ if (_startPosX - entitySelfPropelledArtilleryUnit.getStep() >= 0) {
+ _startPosX -= (int) entitySelfPropelledArtilleryUnit.getStep();
+ }
+ yield true;
+ }
+ case Up -> {
+ if (_startPosY - drawingKeelHeight - entitySelfPropelledArtilleryUnit.getStep() >= 0) {
+ _startPosY -= (int) entitySelfPropelledArtilleryUnit.getStep();
+ }
+ yield true;
+ }
+ case Right -> {
+ if (_startPosX + entitySelfPropelledArtilleryUnit.getStep() <= pictureWidth - drawingSelfPropelledArtilleryUnitWidth) {
+ _startPosX += (int) entitySelfPropelledArtilleryUnit.getStep();
+ }
+ yield true;
+ }
+ case Down -> {
+ if (_startPosY + entitySelfPropelledArtilleryUnit.getStep() <= pictureHeight - drawingSelfPropelledArtilleryUnitHeight + drawingKeelHeight) {
+ _startPosY += (int) entitySelfPropelledArtilleryUnit.getStep();
+ }
+ yield true;
+ }
+ default -> false;
+ };
+ }
+
+ public void drawTransport(Graphics g) {
+ if (entitySelfPropelledArtilleryUnit == null || _startPosX == null || _startPosY == null) {
+ return;
+ }
+
+ Graphics2D g2d = (Graphics2D) g;
+ g2d.setColor(Color.BLACK);
+ g.drawOval(_startPosX + 0, _startPosY + 75, 30, 30);
+ g.drawOval(_startPosX + 90, _startPosY + 75, 30, 30);
+ g.drawRect(_startPosX + 15, _startPosY + 75, 90, 30);
+
+ //границы ЦВЕТ
+ g.fillRect(_startPosX + 25, _startPosY + 40, 35, 30);//башня
+ g.fillOval(_startPosX + 0, _startPosY + 75, 30, 30);
+ g.fillOval(_startPosX + 90, _startPosY + 75, 30, 30);
+ g.fillRect(_startPosX + 15, _startPosY + 75, 90, 30);
+
+ // границы арт. установки
+ g.drawRect(_startPosX + 25, _startPosY + 40, 35, 30);
+ g.drawRect(_startPosX + 0, _startPosY + 65, 120, 13);
+
+ // верхние катки ОТРИСОВКА
+ g.drawOval(_startPosX + 30, _startPosY + 70, 20, 20);
+ g.drawOval(_startPosX + 50, _startPosY + 70, 20, 20);
+ g.drawOval(_startPosX + 70, _startPosY + 70, 20, 20);
+
+ //нижние катки ОТРИСОВКА
+ g.drawOval(_startPosX + 30, _startPosY + 90, 15, 15);
+ g.drawOval(_startPosX + 45, _startPosY + 90, 15, 15);
+ g.drawOval(_startPosX + 60, _startPosY + 90, 15, 15);
+ g.drawOval(_startPosX + 75, _startPosY + 90, 15, 15);
+
+ g.fillOval(_startPosX + 3, _startPosY + 78, 24, 24);
+ g.fillOval(_startPosX + 93, _startPosY + 78, 24, 24);
+
+ int x = _startPosX;
+ if (drawingCrawlerRollers.getCrawlerRollersCount() != null){
+ switch (drawingCrawlerRollers.getCrawlerRollersCount()){
+ case Four:
+ drawingCrawlerRollers.DrawRollers(g,x + 15, _startPosY + 90, 15, 15, entitySelfPropelledArtilleryUnit.getBodyColor());
+ break;
+ case Five:
+ drawingCrawlerRollers.DrawRollers(g,x + 15, _startPosY + 90, 15, 15, entitySelfPropelledArtilleryUnit.getBodyColor());
+ drawingCrawlerRollers.DrawRollers(g,x + 90, _startPosY + 90, 15, 15, entitySelfPropelledArtilleryUnit.getBodyColor());
+ break;
+ case Six:
+ drawingCrawlerRollers.DrawRollers(g,x + 15, _startPosY + 90, 15, 15, entitySelfPropelledArtilleryUnit.getBodyColor());
+ drawingCrawlerRollers.DrawRollers(g,x + 90, _startPosY + 90, 15, 15, entitySelfPropelledArtilleryUnit.getBodyColor());
+ drawingCrawlerRollers.DrawRollers(g,x + 90, _startPosY + 90, 15, 15, entitySelfPropelledArtilleryUnit.getBodyColor());
+ break;
+ }
+ }
+
+ g2d.setColor(entitySelfPropelledArtilleryUnit.getBodyColor());
+ // верхние катки ЦВЕТ
+ g.fillOval(_startPosX + 30, _startPosY + 70, 20, 20);
+ g.fillOval(_startPosX + 50, _startPosY + 70, 20, 20);
+ g.fillOval(_startPosX + 70, _startPosY + 70, 20, 20);
+
+ //нижние катки ЦВЕТ
+ g.fillOval(_startPosX + 30, _startPosY + 90, 15, 15);
+ g.fillOval(_startPosX + 45, _startPosY + 90, 15, 15);
+ g.fillOval(_startPosX + 60, _startPosY + 90, 15, 15);
+ g.fillOval(_startPosX + 75, _startPosY + 90, 15, 15);
+
+ //Большие катки ОТРИСОВКА
+ g.drawOval(_startPosX + 3, _startPosY + 78, 24, 24);
+ g.drawOval(_startPosX + 93, _startPosY + 78, 24, 24);
+
+ g.fillRect(_startPosX + 0, _startPosY + 65, 120, 13);
+
+
+ // Орудийная башня
+ if (entitySelfPropelledArtilleryUnit.getTurretCannon()) {
+ g.fillOval(_startPosX + 26, _startPosY + 35, 50, 30);
+ g.fillRect(_startPosX + 25, _startPosY + 36, 20, 29);
+ g.fillRect(_startPosX + 60, _startPosY + 45, 60, 5);
+ g.fillOval(_startPosX + 113, _startPosY + 42, 20, 10);
+ }
+ g.setColor(Color.RED);
+ // Пусковая батарея
+ if (entitySelfPropelledArtilleryUnit.getLaunchBattery()) {
+ g.fillRect(_startPosX + 0, _startPosY + 45, 20, 20);
+ int[] xPoints = {_startPosX + 0, _startPosX + 0, _startPosX + 20, _startPosX + 20, _startPosX + 0};
+ int[] yPoints = {_startPosY + 15, _startPosY + 65, _startPosY + 65, _startPosY + 45, _startPosY + 15};
+ g.fillPolygon(xPoints, yPoints, 5);
+ g.fillOval(_startPosX + 0, _startPosY + 5, 10, 30);
+ g.fillRect(_startPosX + 10, _startPosY + 15, 20, 5);
+ g.fillRect(_startPosX + 10, _startPosY + 25, 15, 5);
+ }
+ }
+}
+
diff --git a/SelfPropelledArtilleryUnit_Hard/src/EntitySelfPropelledArtilleryUnit.java b/SelfPropelledArtilleryUnit_Hard/src/EntitySelfPropelledArtilleryUnit.java
new file mode 100644
index 0000000..d681057
--- /dev/null
+++ b/SelfPropelledArtilleryUnit_Hard/src/EntitySelfPropelledArtilleryUnit.java
@@ -0,0 +1,48 @@
+import java.awt.*;
+
+public class EntitySelfPropelledArtilleryUnit {
+ private int Speed;
+ public int getSpeed() {
+ return Speed;
+ }
+
+ private double Weight;
+
+ public double getWeight() {
+ return Weight;
+ }
+
+ private Color BodyColor;
+ public Color getBodyColor() {
+ return BodyColor;
+ }
+
+ private Color AdditionalColor;
+ public Color getAdditionalColor() {
+ return AdditionalColor;
+ }
+
+ private double Step;
+ public double getStep() {
+ return (double)Speed * 100 / Weight;
+ }
+
+ private boolean TurretCannon;
+ public boolean getTurretCannon() {
+ return TurretCannon;
+ }
+
+ private boolean LaunchBattery;
+ public boolean getLaunchBattery() {
+ return LaunchBattery;
+ }
+
+ public void Init(int speed, double weight, Color bodyColor, Color additionalColor, boolean turretCannon, boolean launchBattery) {
+ Speed = speed;
+ Weight = weight;
+ BodyColor = bodyColor;
+ AdditionalColor = additionalColor;
+ TurretCannon = turretCannon;
+ LaunchBattery = launchBattery;
+ }
+}
\ No newline at end of file
diff --git a/SelfPropelledArtilleryUnit_Hard/src/FormSelfPropelledArtilleryUnit.form b/SelfPropelledArtilleryUnit_Hard/src/FormSelfPropelledArtilleryUnit.form
new file mode 100644
index 0000000..7743b24
--- /dev/null
+++ b/SelfPropelledArtilleryUnit_Hard/src/FormSelfPropelledArtilleryUnit.form
@@ -0,0 +1,93 @@
+
+
diff --git a/SelfPropelledArtilleryUnit_Hard/src/FormSelfPropelledArtilleryUnit.java b/SelfPropelledArtilleryUnit_Hard/src/FormSelfPropelledArtilleryUnit.java
new file mode 100644
index 0000000..a652d44
--- /dev/null
+++ b/SelfPropelledArtilleryUnit_Hard/src/FormSelfPropelledArtilleryUnit.java
@@ -0,0 +1,107 @@
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Random;
+
+public class FormSelfPropelledArtilleryUnit {
+ protected DrawingSelfPropelledArtilleryUnit _drawningSeaplane = new DrawingSelfPropelledArtilleryUnit();
+ JPanel PanelWrapper;
+ private JPanel PictureBox;
+ private JButton buttonCreate;
+ private JButton buttonRight;
+ private JButton buttonLeft;
+ private JButton buttonDown;
+ private JButton buttonUp;
+
+ private List controls;
+ public FormSelfPropelledArtilleryUnit() {
+ buttonUp.setName("buttonUp");
+ buttonDown.setName("buttonDown");
+ buttonLeft.setName("buttonLeft");
+ buttonRight.setName("buttonRight");
+
+ InitializeControlsRepaintList();
+
+ buttonCreate.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ _drawningSeaplane = new DrawingSelfPropelledArtilleryUnit();
+ Random random = new Random();
+ _drawningSeaplane.Init(random.nextInt(30, 100),
+ random.nextInt(100, 500),
+ new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)),
+ new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)),
+ random.nextBoolean(), random.nextBoolean() );
+ _drawningSeaplane.setPictureSize(PictureBox.getWidth(), PictureBox.getHeight());
+ _drawningSeaplane.setPosition(random.nextInt(35, 100),
+ random.nextInt(35, 100));
+ Draw();
+
+ }
+ });
+ ActionListener buttonMoveClickedListener = new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ String buttonName = ((JButton) e.getSource()).getName();
+ boolean result = false;
+
+ switch (buttonName) {
+ case "buttonUp": {
+ result = _drawningSeaplane.moveTransport(DirectionType.Up);
+ }
+ break;
+ case "buttonDown": {
+ result = _drawningSeaplane.moveTransport(DirectionType.Down);
+ }
+ break;
+ case "buttonLeft": {
+ result = _drawningSeaplane.moveTransport(DirectionType.Left);
+ }
+ break;
+ case "buttonRight": {
+ result = _drawningSeaplane.moveTransport(DirectionType.Right);
+ }
+ break;
+
+ };
+
+ if (result) {
+ Draw();
+ };
+ };
+ };
+ buttonRight.addActionListener(buttonMoveClickedListener);
+ buttonDown.addActionListener(buttonMoveClickedListener);
+ buttonLeft.addActionListener(buttonMoveClickedListener);
+ buttonUp.addActionListener(buttonMoveClickedListener);
+
+ }
+ private void Draw() {
+ if (_drawningSeaplane.EntitySelfPropelledArtilleryUnit() == null) {
+ return;
+ }
+ Graphics g = PictureBox.getGraphics();
+ g.setColor(PictureBox.getBackground());
+ g.fillRect(0,0, PictureBox.getWidth(), PictureBox.getHeight());
+ _drawningSeaplane.drawTransport(g);
+
+ RepaintControls();
+ }
+ private void RepaintControls() {
+ for (JComponent control : controls) {
+ control.repaint();
+ }
+ }
+
+ private void InitializeControlsRepaintList() {
+ controls = new LinkedList<>();
+ controls.add(buttonCreate);
+ controls.add(buttonUp);
+ controls.add(buttonDown);
+ controls.add(buttonLeft);
+ controls.add(buttonRight);
+ }
+}
diff --git a/SelfPropelledArtilleryUnit_Hard/src/Main.java b/SelfPropelledArtilleryUnit_Hard/src/Main.java
new file mode 100644
index 0000000..cbfe257
--- /dev/null
+++ b/SelfPropelledArtilleryUnit_Hard/src/Main.java
@@ -0,0 +1,14 @@
+import javax.swing.*;
+
+public class Main {
+ public static void main(String[] args) {
+ JFrame.setDefaultLookAndFeelDecorated(false);
+ JFrame frame = new JFrame("FormSeaplane");
+ frame.setContentPane(new FormSelfPropelledArtilleryUnit().PanelWrapper);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setLocation(500, 200);
+ frame.pack();
+ frame.setSize(1000, 500);
+ frame.setVisible(true);
+ }
+}
\ No newline at end of file