From 620e76136b5f0490ce3f283620ee0e46eeb623b3 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Fri, 7 Oct 2022 19:26:22 +0400 Subject: [PATCH 1/9] =?UTF-8?q?=D0=9A=D0=BB=D0=B0=D1=81=D1=81=D1=8B=20?= =?UTF-8?q?=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82=D0=B0=20=D0=B8=20=D0=BE?= =?UTF-8?q?=D1=82=D1=80=D0=B8=D1=81=D0=BE=D0=B2=D0=BA=D0=B8=20+=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D1=87=D0=B8=D1=81=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/Direction.java | 6 ++ src/main/java/DrawingArmoredCar.java | 119 +++++++++++++++++++++++++ src/main/java/DrawningCaterpillar.java | 38 ++++++++ src/main/java/EntityArmoredCar.java | 40 +++++++++ src/main/java/NumRinks.java | 6 ++ 5 files changed, 209 insertions(+) create mode 100644 src/main/java/Direction.java create mode 100644 src/main/java/DrawingArmoredCar.java create mode 100644 src/main/java/DrawningCaterpillar.java create mode 100644 src/main/java/EntityArmoredCar.java create mode 100644 src/main/java/NumRinks.java diff --git a/src/main/java/Direction.java b/src/main/java/Direction.java new file mode 100644 index 0000000..a641b80 --- /dev/null +++ b/src/main/java/Direction.java @@ -0,0 +1,6 @@ +public enum Direction { + Up, + Down, + Left, + Right +} diff --git a/src/main/java/DrawingArmoredCar.java b/src/main/java/DrawingArmoredCar.java new file mode 100644 index 0000000..7e6ef22 --- /dev/null +++ b/src/main/java/DrawingArmoredCar.java @@ -0,0 +1,119 @@ +import java.awt.*; +import java.util.Random; + +public class DrawingArmoredCar { + public EntityArmoredCar armoredCar; + + private float startPosX; + + private float startPosY; + + private int pictureWidth; + + private int pictureHeight; + + private static final int carWidth = 80; + + private static final int carHeight = 50; + + private DrawningCaterpillar drawningCaterpillar; + + public void Init(int speed, float weight, Color bodyColor) { + this.armoredCar = new EntityArmoredCar(); + this.armoredCar.init(speed, weight, bodyColor); + Random r = new Random(); + this.drawningCaterpillar = new DrawningCaterpillar(); + this.drawningCaterpillar.Init(r.nextInt(4) + 3, bodyColor); + } + + + public void SetPosition(int x, int y, int width, int height) { + if (x > 0 && y > 0 && x + carWidth < width && y + carHeight < height) { + startPosX = x; + startPosY = y; + pictureWidth = width; + pictureHeight = height; + } + } + + + public void MoveTransport(Direction direction) { + if (pictureWidth < 1|| pictureHeight < 1) + { + return; + } + switch (direction) + { + // вправо + case Right: + if (startPosX + carWidth + armoredCar.step < pictureWidth) + { + startPosX += armoredCar.step; + } + break; + //влево + case Left: + if (startPosX - armoredCar.step > 0) + { + startPosX -= armoredCar.step; + } + break; + //вверх + case Up: + if (startPosY - armoredCar.step > 0) + { + startPosY -= armoredCar.step; + } + break; + //вниз + case Down: + if (startPosY + carHeight + armoredCar.step < pictureHeight) + { + startPosY += armoredCar.step; + } + break; + } + } + + + public void DrawTransport(Graphics2D g2d) + { + if (startPosX < 0 || startPosY < 0 + || pictureHeight < 1 || pictureWidth < 1) + { + return; + } + // отрисовка корпуса и гусеницы + g2d.setPaint(armoredCar.getBodyColor()); + g2d.fillRect((int ) startPosX + 20, (int) startPosY, 40, 20); + g2d.setPaint(Color.LIGHT_GRAY); + g2d.fillRect((int ) startPosX, (int ) startPosY + 20, 80, 20); + + g2d.fillOval((int ) startPosX, (int ) startPosY + 30, 20, 20); + g2d.fillOval((int ) startPosX + 80 - 20, (int ) startPosY + 30, 20, 20); + g2d.fillRect((int ) startPosX + 15, (int ) startPosY + 20, 60, 30); + // отрисовка катков в гусенице + drawningCaterpillar.DrawCaterpillar(g2d, (int)startPosX, (int)startPosY); + } + + + public void ChangeBorders(int width, int height) + { + pictureWidth = width; + pictureHeight = height; + if (pictureWidth <= carWidth || pictureHeight <= carHeight) + { + pictureWidth = 0; + pictureHeight = 0; + return; + } + if (startPosX + carWidth > pictureWidth) + { + startPosX = pictureWidth - carWidth; + } + if (startPosY + carHeight > pictureHeight) + { + startPosY = pictureHeight - carHeight; + } + } +} diff --git a/src/main/java/DrawningCaterpillar.java b/src/main/java/DrawningCaterpillar.java new file mode 100644 index 0000000..3dc9840 --- /dev/null +++ b/src/main/java/DrawningCaterpillar.java @@ -0,0 +1,38 @@ +import java.awt.*; + +public class DrawningCaterpillar { + private NumRinks numRinks = NumRinks.Four; + private Color color; + + public void Init(int n, Color color) { + setNumRinks(n); + this.color = color; + } + + public void setNumRinks(int n) { + switch (n) { + case 4 -> numRinks = NumRinks.Four; + + case 5 -> numRinks = NumRinks.Five; + + case 6 -> numRinks = NumRinks.Six; + + default -> { + break; + } + } + + } + + public void DrawCaterpillar(Graphics2D g2d, int startPosX, int startPosY) + { + color = color != null ? color : Color.YELLOW; + g2d.setPaint(color); + int size = numRinks == NumRinks.Four ? 15 : 10; + int dist = numRinks == NumRinks.Four ? 20 : 13; + startPosX = numRinks == NumRinks.Five ? startPosX + 5 : startPosX; + for (int i = 0; i < numRinks.val(); i++) { + g2d.fillOval(startPosX + dist * i, startPosY + 30, size, size); + } + } +} diff --git a/src/main/java/EntityArmoredCar.java b/src/main/java/EntityArmoredCar.java new file mode 100644 index 0000000..099a7a8 --- /dev/null +++ b/src/main/java/EntityArmoredCar.java @@ -0,0 +1,40 @@ +import java.awt.*; + +public class EntityArmoredCar { + + private int speed; + private float weight; + private Color bodyColor; + public float step; + + public void init(int speed, float weight, Color bodyColor) { + this.speed = speed; + this.weight = weight; + this.bodyColor = bodyColor; + this.step = speed * 100 / weight; + } + + public int getSpeed() { + return speed; + } + + public void setSpeed(int speed) { + this.speed = speed; + } + + public float getWeight() { + return weight; + } + + public void setWeight(float weight) { + this.weight = weight; + } + + public Color getBodyColor() { + return bodyColor; + } + + public void setBodyColor(Color bodyColor) { + this.bodyColor = bodyColor; + } +} diff --git a/src/main/java/NumRinks.java b/src/main/java/NumRinks.java new file mode 100644 index 0000000..846cf67 --- /dev/null +++ b/src/main/java/NumRinks.java @@ -0,0 +1,6 @@ +public enum NumRinks { + Four{public int val() {return 4;}}, + Five{public int val() {return 5;}}, + Six{public int val() {return 6;}}; + public abstract int val(); +} From 01959c985035d34e23a31f2afbcd45bd9a98de0c Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Fri, 7 Oct 2022 19:33:25 +0400 Subject: [PATCH 2/9] =?UTF-8?q?=D0=A4=D0=BE=D1=80=D0=BC=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/FormCar.form | 105 +++++++++++++++++++++++++++++++ src/main/java/FormCar.java | 123 +++++++++++++++++++++++++++++++++++++ src/main/java/Program.java | 2 +- 3 files changed, 229 insertions(+), 1 deletion(-) create mode 100644 src/main/java/FormCar.form create mode 100644 src/main/java/FormCar.java diff --git a/src/main/java/FormCar.form b/src/main/java/FormCar.form new file mode 100644 index 0000000..ad5b35a --- /dev/null +++ b/src/main/java/FormCar.form @@ -0,0 +1,105 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/FormCar.java b/src/main/java/FormCar.java new file mode 100644 index 0000000..3569b7c --- /dev/null +++ b/src/main/java/FormCar.java @@ -0,0 +1,123 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.util.Random; + +public class FormCar extends JFrame{ + private JButton buttonUp; + private JButton buttonDown; + private JButton buttonRight; + private JButton buttonLeft; + private JPanel mainPanel; + private JPanel drawPanel; + private JButton buttonCreate; + private JLabel labelSpeed; + private JLabel labelWeight; + private JLabel labelColor; + + + private DrawingArmoredCar armoredCar; + + public FormCar() { + super("Бронированная машина"); + setBounds(100, 100, 700, 700); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + + addComponentListener(new ComponentAdapter() { + public void componentResized(ComponentEvent componentEvent) { + if (armoredCar != null) { + armoredCar.ChangeBorders(drawPanel.getWidth(), drawPanel.getHeight()); + repaint(); + } + } + }); + + labelSpeed.setText("Скорость: "); + labelWeight.setText("Вес: "); + labelColor.setText("Цвет: "); + + Canvas canvas = new Canvas(); + drawPanel.add(canvas); + + buttonCreate.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + Random rnd = new Random(); + armoredCar = new DrawingArmoredCar(); + armoredCar.Init(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000, + new Color(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256))); + + armoredCar.SetPosition(rnd.nextInt(90) + 10, rnd.nextInt(90) + 10, + drawPanel.getWidth(), drawPanel.getHeight()); + + canvas.setArmoredCar(armoredCar); + labelSpeed.setText("Скорость: " + armoredCar.armoredCar.getSpeed()); + labelWeight.setText("Вес: " + armoredCar.armoredCar.getWeight()); + labelColor.setText("Цвет: " + armoredCar.armoredCar.getWeight()); + } + }); + + buttonUp.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + if (armoredCar != null) + armoredCar.MoveTransport(Direction.Up); + canvas.repaint(); + } + }); + + buttonDown.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + if (armoredCar != null) + armoredCar.MoveTransport(Direction.Down); + canvas.repaint(); + } + }); + + buttonLeft.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + if (armoredCar != null) + armoredCar.MoveTransport(Direction.Left); + canvas.repaint(); + } + }); + + buttonRight.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + if (armoredCar != null) + armoredCar.MoveTransport(Direction.Right); + canvas.repaint(); + } + }); + + setContentPane(mainPanel); + setVisible(true); + } +} + +class Canvas extends JPanel { + private DrawingArmoredCar armoredCar; + public Canvas () { + super(); + } + + public void setArmoredCar(DrawingArmoredCar armoredCar) { + this.armoredCar = armoredCar; + } + + public void paintComponent(Graphics g) { + super.paintComponent(g); + if (armoredCar != null) { + Graphics2D g2d = (Graphics2D) g; + armoredCar.DrawTransport(g2d); + } + super.repaint(); + } +} diff --git a/src/main/java/Program.java b/src/main/java/Program.java index b57b1a9..5182f41 100644 --- a/src/main/java/Program.java +++ b/src/main/java/Program.java @@ -3,6 +3,6 @@ import java.awt.*; public class Program { public static void main(String[] args) { - + new FormCar(); } } From 2d676c0a0a3752840681ab0f619d17e6eeba49f4 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Fri, 7 Oct 2022 20:31:45 +0400 Subject: [PATCH 3/9] =?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=B0=D1=80=D1=82=D0=B8=D0=BD=D0=BE?= =?UTF-8?q?=D0=BA=20=D0=BD=D0=B0=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/FormCar.form | 33 ++++++++++++++++++--------------- src/main/java/FormCar.java | 5 +++-- src/main/resources/Down.png | Bin 0 -> 20504 bytes src/main/resources/Left.png | Bin 0 -> 20314 bytes src/main/resources/Right.png | Bin 0 -> 20434 bytes src/main/resources/Up.png | Bin 0 -> 1817 bytes 6 files changed, 21 insertions(+), 17 deletions(-) create mode 100644 src/main/resources/Down.png create mode 100644 src/main/resources/Left.png create mode 100644 src/main/resources/Right.png create mode 100644 src/main/resources/Up.png diff --git a/src/main/java/FormCar.form b/src/main/java/FormCar.form index ad5b35a..661fd81 100644 --- a/src/main/java/FormCar.form +++ b/src/main/java/FormCar.form @@ -14,9 +14,7 @@ - - - + @@ -40,21 +38,33 @@ + + + + + + + + + - + + + - + - + + @@ -62,18 +72,11 @@ - + + - - - - - - - - diff --git a/src/main/java/FormCar.java b/src/main/java/FormCar.java index 3569b7c..cf851af 100644 --- a/src/main/java/FormCar.java +++ b/src/main/java/FormCar.java @@ -18,7 +18,6 @@ public class FormCar extends JFrame{ private JLabel labelWeight; private JLabel labelColor; - private DrawingArmoredCar armoredCar; public FormCar() { @@ -26,7 +25,6 @@ public class FormCar extends JFrame{ setBounds(100, 100, 700, 700); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent componentEvent) { if (armoredCar != null) { @@ -40,6 +38,9 @@ public class FormCar extends JFrame{ labelWeight.setText("Вес: "); labelColor.setText("Цвет: "); + + + Canvas canvas = new Canvas(); drawPanel.add(canvas); diff --git a/src/main/resources/Down.png b/src/main/resources/Down.png new file mode 100644 index 0000000000000000000000000000000000000000..b08133ad710143ef4cb796191c73a4af50cf58b3 GIT binary patch literal 20504 zcmeI3do+~m9>?D?<|dbflH_hHHRk4$IfK2EQA8w{qof%#X(;0|&I~2p3FQ`hZ=?%R zNmDLcLb`56B_u?<5J~BvFvFNRFO~M$YyYv|^T%21tn)rI?^?h2neX$w@9*<|*P7>j z*80iXWv_twPV{wj0D(XN+rSSX>t1->LBQD#04^?oDF6Ui01eCoV0e~u9dk~DU-~l(7089WT026=- zzy$s;33zitSX_RDp4$#CkE`dv;_$fPdL*J5(TqeSl1OGGOUf#9;IFC3L^7F5w5F0M zdL#>~If+Un0RTD$`E^yIs+}S~7ZcM`XJaIh2monm-{RAVZ>yVcD;M1Sna2aKT>dXj z3MUN{fC<0^U;;3KIRgK_+MrlbEy%#1^??J>2;`SF1sdEj(E?ClAGmj-dIGUzF3v$L z`=SB&S>zC3cTZIF<>bD`DCI8~-}ZU@%w7$EkhRM?0eb+8Mq|(@ECz$Y;jjvd>Pm|9 z<|!^-pr)d}R7+Q9sg}03o{^b}p212(ZS7@N%U2Rf=H}+QCe}8q$TTyGIeBIh1P+H& zoTsR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ngvEc57bS?qLkU(t)RSHzC;YAG?t_O^VYKOFWk?a2Gp>#!}G-qq}0 zbJF?w(AGBZ3f`XD`1a^>!?^J^i`i{nDmFJ~Ikyj7vxSi@ivC$#Z^VP{K zHvo~BGnBn*E3ZUls%U24_B^(xqAx9@X6K9K`it%tHaMjQxB9%6uH0kPas$6Zmt8&m zsP%?#^Uxx~&NqvD?Z`Pm!%O5DAUVC7{i?>X`%Qd*^Oz4UJHFBjLwX#Sm&f-IA58gP zFJX$W?M)hS?%tj~;&JB~d(Vw6SNn!8yX_tAXbc-vS?qBO*(SetNw4>TRj!0P)prm< zf&sj7$@$EtQ>WH86g(d3d?)ZuG-aocTht5^3P;7l*2uA!z3gr-b zN)r3;vM<>G;vhbo5!>4Joq%VXn|Ge3RfjQ@jQIEe!pZ0cj5b~DXUVN*2Gb~ zlyP+Bdt?8qw?=tw*X&y^yxBjtS4YIp8ri$OsT4_R+Br0tHH^jBnX#btv1qY15k!?u)9uDj|4i!dterR^14vJfEA2@iSH6=Qc+MrGG9WHG`E0_9 Kcgg0mj(-7~mVkx; literal 0 HcmV?d00001 diff --git a/src/main/resources/Left.png b/src/main/resources/Left.png new file mode 100644 index 0000000000000000000000000000000000000000..bc5a5cc561511379139667a35bbbc4d2151efa04 GIT binary patch literal 20314 zcmeI3X;2f{8iqRyNeG~VAjrO`APm_c0vQ&SRlJBS0y?7*NPx%^Hf0gaFus$0`1Y3l34drtTF^jnqF zr|J{8i@Sj(j&>XD00aU7_<$ck%v%;_8^iJk04FCv9{>OxfB~ccBp9s%Pka$_01Au| z;0HjE7y9=hDD$yAs3}Ti0qA)RfU6x+1+ZYBGSQu%jb2HwUt#*qXKsRunrzlT0Fz2xJn8OeT=m7?~Oae@#UpQ7AN$8I5eD zNv6__$zT8gm_w*9s}fn&L+FK=lyP`IMv+JWkdg5Y1$mhD0_tHrCKJvoNKY6O4>0bCVz>B_*Y$ zq?Kf3lqg!NS`^4ldcBf{IV6syp{a9)aEn$Yl;2% zKV`O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TSDt+)tO;cxg!XjnexA?mZi0 z0p3$#dILAQC!hcJv8czZ-RaIKJn>jY1XY<0(_8E_r^J5%(-} zxZ>2ZBIfk@lXf~)=_SRZI+xAkmUf69 zwr=i<-@5CRQonmkKXXxH`58W!J9$@!PZjO%GhfWD54RvF*6m2y`dkpv?-`a5T2%a| zFnjQon}F*d;+TotnnK*Wdi&N7W9H3-W-+jTZ&mJ$O~6#!SaGGwJpr+`?g>AIQwvrI zCVM-vZ{@Y0o$;yRdADQ;Roezn70=3vfob}P6<-citOa8eF|ac}X{5-Oz5lhEN+LMn znHmvy+YCvM-sGBekCu>I+az=FsH<*gRN|K718bYSQOKI}<|-rC^H9teBUCcJq`-2| z<7w_qx)PDJ>6K87K zi&kB-R;bB+7OXJ+L^dYiSbv8=YQM&Nz9~z$F=MjlNGWqbkU6-0XCXTXo83d2qE)K# oT!Mv`!xQV9ZS6KUynV|QdJfbd*kDUlWb=&@0{yivgEfu+0fEF6g#Z8m literal 0 HcmV?d00001 diff --git a/src/main/resources/Right.png b/src/main/resources/Right.png new file mode 100644 index 0000000000000000000000000000000000000000..f98121923af1a0760a844fcbf99d2f5d360dc5dc GIT binary patch literal 20434 zcmeI3X;4#F8^>=5kc5C31VoAgL5hfwjWq%h1u;?-0ZoICg+}+ zN7f~K3d~)*n!Xx9AP~Sd@B_$tG}D}-xxN74>Iy6c000dr0$4x}jJ^g>yb)>u5{wbx z2SAW!`}ZNpA7XV-b0(P!$bZlP=*9sZ00s6bgXfz70JmCa0F2P!0XLWcOaLYT6MzZ8 z1pbu-7~Bvxj~}7u=Ff}d={d2vk-Ts{648ukMj{ePBr}pF#o8SBdnz)KOr{cTs3eLW z$%1N5q>{)0pm-4Zc~yebIVe9H6EibD#7H6$05UVb#6KgxtZu%nTrhKI9uK^7`B$10 zP8ucv6MzZ81YiQQ1pa%qL9wD*kb%GI0|zJ~ke}8Rir|ikHlP6ZfqN&o!-%hDfcz$yT(sEATjK%-D73VU#rIYc0?={Mu-V@ltaO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#(T7GrPGU5kvLeH6UWu=fuzXx`-{i6H*CE;bO8*lWNJnpO^2TTkG9%Bv0F0CpP zn5=)xw-22@Ch!x8)-HO|yk%SaXo{TMM(Fx4zraRvB}$zTw7upR=2C>udU7ZWbC)nyKSbmx8TF2E=>S-4spU Jrt8VN{{tKDS;YVV literal 0 HcmV?d00001 diff --git a/src/main/resources/Up.png b/src/main/resources/Up.png new file mode 100644 index 0000000000000000000000000000000000000000..9afd579d7a3bfa8d22b1e03758e15290425a83d3 GIT binary patch literal 1817 zcmbV}do*q=dWjbe?FgcKIeQc=kq!rXdL

Xt+BSt^+hd zW7Bq9S51Q>CovXrhIZ)%l~~LD^5c#^L_0t&h7s+G&VhG{-LF{`!Tntm)F<-vA<00-%1w`h)C$xCk&868-@iqvk>&li)xR&>GuqH8;5)!JLdUu&_(V8tyNs ztnbpYv_C2$hI~DOGulBC>=difekJ?=z%KnQvOmE7JO7vva=IznHPc;893J^#$fuZrjQZN5misB8nSRcJ9O2FO*)!j>CbC)YJkG7( zJ%q_|Ja&)f!}pPL9N6;@D`w^LGBOB0Y(k>Fo#|r^=7{k5Q;j#GboXQn+AiH+VfklJ zr3yo){H!$v@4p&*EzMB;exB0av{axN@c!(Fkmio)M*1#4fgAWrYu>R>=-B5%qJ&Y5 zZcbD25I}}OK$xhU5SAzRN;uBh86xtRJ35p7t)fa~Rtt%$xl{6wVm5>sqL$CYB@cW5 z9aDatQ9AlI$YJ~)R!F$%Ym7>F%Pj~r<1#Y&&D|3d0jWNVXU6Iq3&;;^#&G-0U!w{N zCfeg~M=KYe+NH$!=9Z&utLI*1wy<|b+`B=OP$|U<_sv9a0`*v>^{Ms}1+$?iN@m$B zXFVR$=W*uZljG~2h?{MnmW}YfV(d;fCYM?9b0-UDOBjna(@RIYC*M#O6TO))eQB-q zN4wFHSoh>bYAQw}%-Qo=Z)$ATspn<>y51!vNtYSgt^BpL2a(pN^B#@VEQ(jW>{}aK zr7jm`zTzONtWL1}z^|DVXJj=0;%Qh@{J5Oc^*F)&tasP1g1{F_o9Q!(Jx`XnMOK1((qi@NyIU$I zb7ohi-}UqPdu_Vnm3nwQvjcg%%!y7HzJ`E@id3N2?Gg=@Lx7HG|8-hHELlRd{*A4G6dqh3pzeVbDR(Anw*42%I;QM-?linh@wK&sViW zpvKN5gR8qrdD1Z{y2Z;%n37AbLSP?JtUGLBnKmP*8>7Kb5xzP@f+e2 z2xR5Y9A0N^s%XiURBZ51u#KzIpKlbZ{+o7`Y!IyUtUX+7kpo1X{DH1k9#eUUJy<)J zG$!Iji5mjCpDof~b@BBaB?~7GK>*jrU4Vey+ZG61v}0tZ7SYHi9iu^mO8RPazl^oF zu58*i@#H6i4#u}gcZu7q>xLDd*X7kaZr!!}eytHZHE{V(Y-h2!jMu$v=xOkQ=uOM$ zMoKumSFzbGeJSCBU$w~z<0HnAj@$Q)eQNldi}9|GhT~6 Date: Sat, 22 Oct 2022 18:37:02 +0400 Subject: [PATCH 4/9] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/DrawingArmoredCar.java | 12 ++++-------- ...wningCaterpillar.java => DrawingCaterpillar.java} | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) rename src/main/java/{DrawningCaterpillar.java => DrawingCaterpillar.java} (96%) diff --git a/src/main/java/DrawingArmoredCar.java b/src/main/java/DrawingArmoredCar.java index 7e6ef22..a0e81b1 100644 --- a/src/main/java/DrawingArmoredCar.java +++ b/src/main/java/DrawingArmoredCar.java @@ -16,17 +16,16 @@ public class DrawingArmoredCar { private static final int carHeight = 50; - private DrawningCaterpillar drawningCaterpillar; + private DrawingCaterpillar drawingCaterpillar; public void Init(int speed, float weight, Color bodyColor) { this.armoredCar = new EntityArmoredCar(); this.armoredCar.init(speed, weight, bodyColor); Random r = new Random(); - this.drawningCaterpillar = new DrawningCaterpillar(); - this.drawningCaterpillar.Init(r.nextInt(4) + 3, bodyColor); + this.drawingCaterpillar = new DrawingCaterpillar(); + this.drawingCaterpillar.Init(r.nextInt(4) + 3, bodyColor); } - public void SetPosition(int x, int y, int width, int height) { if (x > 0 && y > 0 && x + carWidth < width && y + carHeight < height) { startPosX = x; @@ -36,7 +35,6 @@ public class DrawingArmoredCar { } } - public void MoveTransport(Direction direction) { if (pictureWidth < 1|| pictureHeight < 1) { @@ -75,7 +73,6 @@ public class DrawingArmoredCar { } } - public void DrawTransport(Graphics2D g2d) { if (startPosX < 0 || startPosY < 0 @@ -93,10 +90,9 @@ public class DrawingArmoredCar { g2d.fillOval((int ) startPosX + 80 - 20, (int ) startPosY + 30, 20, 20); g2d.fillRect((int ) startPosX + 15, (int ) startPosY + 20, 60, 30); // отрисовка катков в гусенице - drawningCaterpillar.DrawCaterpillar(g2d, (int)startPosX, (int)startPosY); + drawingCaterpillar.DrawCaterpillar(g2d, (int)startPosX, (int)startPosY); } - public void ChangeBorders(int width, int height) { pictureWidth = width; diff --git a/src/main/java/DrawningCaterpillar.java b/src/main/java/DrawingCaterpillar.java similarity index 96% rename from src/main/java/DrawningCaterpillar.java rename to src/main/java/DrawingCaterpillar.java index 3dc9840..3a1e4be 100644 --- a/src/main/java/DrawningCaterpillar.java +++ b/src/main/java/DrawingCaterpillar.java @@ -1,6 +1,6 @@ import java.awt.*; -public class DrawningCaterpillar { +public class DrawingCaterpillar { private NumRinks numRinks = NumRinks.Four; private Color color; From 7ee149d5bc73c1e082d25f108fcd2ef27d8c1ff1 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sat, 22 Oct 2022 18:38:02 +0400 Subject: [PATCH 5/9] =?UTF-8?q?=D0=9A=D0=BB=D0=B0=D1=81=D1=81=20Canvas=20?= =?UTF-8?q?=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=20-=20=D0=B2=D1=81=D1=8F?= =?UTF-8?q?=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=D0=B0=20=D0=B2=20=D0=BC?= =?UTF-8?q?=D0=B5=D1=82=D0=BE=D0=B4=20drawPanel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/FormCar.form | 4 ++-- src/main/java/FormCar.java | 48 ++++++++++++++------------------------ 2 files changed, 20 insertions(+), 32 deletions(-) diff --git a/src/main/java/FormCar.form b/src/main/java/FormCar.form index 661fd81..3055d42 100644 --- a/src/main/java/FormCar.form +++ b/src/main/java/FormCar.form @@ -12,12 +12,12 @@ - + - + diff --git a/src/main/java/FormCar.java b/src/main/java/FormCar.java index cf851af..3e61b40 100644 --- a/src/main/java/FormCar.java +++ b/src/main/java/FormCar.java @@ -38,12 +38,6 @@ public class FormCar extends JFrame{ labelWeight.setText("Вес: "); labelColor.setText("Цвет: "); - - - - Canvas canvas = new Canvas(); - drawPanel.add(canvas); - buttonCreate.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { @@ -55,7 +49,6 @@ public class FormCar extends JFrame{ armoredCar.SetPosition(rnd.nextInt(90) + 10, rnd.nextInt(90) + 10, drawPanel.getWidth(), drawPanel.getHeight()); - canvas.setArmoredCar(armoredCar); labelSpeed.setText("Скорость: " + armoredCar.armoredCar.getSpeed()); labelWeight.setText("Вес: " + armoredCar.armoredCar.getWeight()); labelColor.setText("Цвет: " + armoredCar.armoredCar.getWeight()); @@ -67,7 +60,7 @@ public class FormCar extends JFrame{ public void actionPerformed(ActionEvent actionEvent) { if (armoredCar != null) armoredCar.MoveTransport(Direction.Up); - canvas.repaint(); + drawPanel.repaint(); } }); @@ -76,7 +69,8 @@ public class FormCar extends JFrame{ public void actionPerformed(ActionEvent actionEvent) { if (armoredCar != null) armoredCar.MoveTransport(Direction.Down); - canvas.repaint(); + drawPanel.repaint(); + } }); @@ -85,7 +79,7 @@ public class FormCar extends JFrame{ public void actionPerformed(ActionEvent actionEvent) { if (armoredCar != null) armoredCar.MoveTransport(Direction.Left); - canvas.repaint(); + drawPanel.repaint(); } }); @@ -94,31 +88,25 @@ public class FormCar extends JFrame{ public void actionPerformed(ActionEvent actionEvent) { if (armoredCar != null) armoredCar.MoveTransport(Direction.Right); - canvas.repaint(); + drawPanel.repaint(); } }); setContentPane(mainPanel); setVisible(true); } -} -class Canvas extends JPanel { - private DrawingArmoredCar armoredCar; - public Canvas () { - super(); + private void createUIComponents() { + drawPanel = new JPanel() { + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + if (armoredCar != null) { + Graphics2D g2d = (Graphics2D) g; + armoredCar.DrawTransport(g2d); + } + super.repaint(); + } + }; } - - public void setArmoredCar(DrawingArmoredCar armoredCar) { - this.armoredCar = armoredCar; - } - - public void paintComponent(Graphics g) { - super.paintComponent(g); - if (armoredCar != null) { - Graphics2D g2d = (Graphics2D) g; - armoredCar.DrawTransport(g2d); - } - super.repaint(); - } -} +} \ No newline at end of file From 9bf470f992ed063b4a2770a42dae503fd7f457d7 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sat, 22 Oct 2022 20:30:56 +0400 Subject: [PATCH 6/9] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F:=20=D0=B7=D0=B0=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=BC=D0=BE=D0=B4=D0=B8=D1=84=D0=B8=D0=BA=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B0=20=D0=BF=D0=BE=D0=BB=D1=8F=20=D0=BD=D0=B0=20?= =?UTF-8?q?private,=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20getter-=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=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/DrawingCaterpillar.java | 1 - src/main/java/FormCar.java | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/DrawingArmoredCar.java b/src/main/java/DrawingArmoredCar.java index a0e81b1..cc471df 100644 --- a/src/main/java/DrawingArmoredCar.java +++ b/src/main/java/DrawingArmoredCar.java @@ -2,7 +2,7 @@ import java.awt.*; import java.util.Random; public class DrawingArmoredCar { - public EntityArmoredCar armoredCar; + private EntityArmoredCar armoredCar; private float startPosX; @@ -18,6 +18,10 @@ public class DrawingArmoredCar { private DrawingCaterpillar drawingCaterpillar; + public EntityArmoredCar getArmoredCar() { + return armoredCar; + } + public void Init(int speed, float weight, Color bodyColor) { this.armoredCar = new EntityArmoredCar(); this.armoredCar.init(speed, weight, bodyColor); @@ -27,7 +31,7 @@ public class DrawingArmoredCar { } public void SetPosition(int x, int y, int width, int height) { - if (x > 0 && y > 0 && x + carWidth < width && y + carHeight < height) { + if (x >= 0 && y >= 0 && x + carWidth < width && y + carHeight < height) { startPosX = x; startPosY = y; pictureWidth = width; diff --git a/src/main/java/DrawingCaterpillar.java b/src/main/java/DrawingCaterpillar.java index 3a1e4be..ae2fb0c 100644 --- a/src/main/java/DrawingCaterpillar.java +++ b/src/main/java/DrawingCaterpillar.java @@ -21,7 +21,6 @@ public class DrawingCaterpillar { break; } } - } public void DrawCaterpillar(Graphics2D g2d, int startPosX, int startPosY) diff --git a/src/main/java/FormCar.java b/src/main/java/FormCar.java index 3e61b40..176f0b0 100644 --- a/src/main/java/FormCar.java +++ b/src/main/java/FormCar.java @@ -49,9 +49,9 @@ public class FormCar extends JFrame{ armoredCar.SetPosition(rnd.nextInt(90) + 10, rnd.nextInt(90) + 10, drawPanel.getWidth(), drawPanel.getHeight()); - labelSpeed.setText("Скорость: " + armoredCar.armoredCar.getSpeed()); - labelWeight.setText("Вес: " + armoredCar.armoredCar.getWeight()); - labelColor.setText("Цвет: " + armoredCar.armoredCar.getWeight()); + labelSpeed.setText("Скорость: " + armoredCar.getArmoredCar().getSpeed()); + labelWeight.setText("Вес: " + armoredCar.getArmoredCar().getWeight()); + labelColor.setText("Цвет: " + armoredCar.getArmoredCar().getWeight()); } }); From bcca5be3f12bbf2b9efc128713195d18fe2324db Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sat, 22 Oct 2022 20:40:30 +0400 Subject: [PATCH 7/9] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/DrawingArmoredCar.java | 2 +- src/main/java/FormCar.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/DrawingArmoredCar.java b/src/main/java/DrawingArmoredCar.java index cc471df..b4fa674 100644 --- a/src/main/java/DrawingArmoredCar.java +++ b/src/main/java/DrawingArmoredCar.java @@ -27,7 +27,7 @@ public class DrawingArmoredCar { this.armoredCar.init(speed, weight, bodyColor); Random r = new Random(); this.drawingCaterpillar = new DrawingCaterpillar(); - this.drawingCaterpillar.Init(r.nextInt(4) + 3, bodyColor); + this.drawingCaterpillar.Init(r.nextInt(4, 7), bodyColor); } public void SetPosition(int x, int y, int width, int height) { diff --git a/src/main/java/FormCar.java b/src/main/java/FormCar.java index 176f0b0..4f95a8e 100644 --- a/src/main/java/FormCar.java +++ b/src/main/java/FormCar.java @@ -43,15 +43,15 @@ public class FormCar extends JFrame{ public void actionPerformed(ActionEvent actionEvent) { Random rnd = new Random(); armoredCar = new DrawingArmoredCar(); - armoredCar.Init(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000, + armoredCar.Init(rnd.nextInt(100,300), rnd.nextInt(1000, 2000), new Color(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256))); - armoredCar.SetPosition(rnd.nextInt(90) + 10, rnd.nextInt(90) + 10, + armoredCar.SetPosition(rnd.nextInt(10, 100), rnd.nextInt(10, 100), drawPanel.getWidth(), drawPanel.getHeight()); labelSpeed.setText("Скорость: " + armoredCar.getArmoredCar().getSpeed()); labelWeight.setText("Вес: " + armoredCar.getArmoredCar().getWeight()); - labelColor.setText("Цвет: " + armoredCar.getArmoredCar().getWeight()); + labelColor.setText("Цвет: " + armoredCar.getArmoredCar().getBodyColor().getRGB()); } }); From a201dbeeb14f7b311c0538b472de6d1cf73ceeb3 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sat, 22 Oct 2022 20:42:40 +0400 Subject: [PATCH 8/9] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/{FormCar.form => FormArmoredCar.form} | 2 +- src/main/java/{FormCar.java => FormArmoredCar.java} | 4 ++-- src/main/java/Program.java | 5 +---- 3 files changed, 4 insertions(+), 7 deletions(-) rename src/main/java/{FormCar.form => FormArmoredCar.form} (99%) rename src/main/java/{FormCar.java => FormArmoredCar.java} (98%) diff --git a/src/main/java/FormCar.form b/src/main/java/FormArmoredCar.form similarity index 99% rename from src/main/java/FormCar.form rename to src/main/java/FormArmoredCar.form index 3055d42..e82df6d 100644 --- a/src/main/java/FormCar.form +++ b/src/main/java/FormArmoredCar.form @@ -1,5 +1,5 @@ -

+ diff --git a/src/main/java/FormCar.java b/src/main/java/FormArmoredCar.java similarity index 98% rename from src/main/java/FormCar.java rename to src/main/java/FormArmoredCar.java index 4f95a8e..045cdaa 100644 --- a/src/main/java/FormCar.java +++ b/src/main/java/FormArmoredCar.java @@ -6,7 +6,7 @@ import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.util.Random; -public class FormCar extends JFrame{ +public class FormArmoredCar extends JFrame{ private JButton buttonUp; private JButton buttonDown; private JButton buttonRight; @@ -20,7 +20,7 @@ public class FormCar extends JFrame{ private DrawingArmoredCar armoredCar; - public FormCar() { + public FormArmoredCar() { super("Бронированная машина"); setBounds(100, 100, 700, 700); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); diff --git a/src/main/java/Program.java b/src/main/java/Program.java index 5182f41..2d1f91a 100644 --- a/src/main/java/Program.java +++ b/src/main/java/Program.java @@ -1,8 +1,5 @@ -import javax.swing.*; -import java.awt.*; - public class Program { public static void main(String[] args) { - new FormCar(); + new FormArmoredCar(); } } From 34fcedd0b7dbae07623ccf8986b1a8f8c535f22a Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sat, 22 Oct 2022 20:46:18 +0400 Subject: [PATCH 9/9] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/EntityArmoredCar.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/main/java/EntityArmoredCar.java b/src/main/java/EntityArmoredCar.java index 099a7a8..f1d54e5 100644 --- a/src/main/java/EntityArmoredCar.java +++ b/src/main/java/EntityArmoredCar.java @@ -18,23 +18,11 @@ public class EntityArmoredCar { return speed; } - public void setSpeed(int speed) { - this.speed = speed; - } - public float getWeight() { return weight; } - public void setWeight(float weight) { - this.weight = weight; - } - public Color getBodyColor() { return bodyColor; } - - public void setBodyColor(Color bodyColor) { - this.bodyColor = bodyColor; - } }