From 523b5466b2650c3a4ff6423dddc857a82c932b75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D1=88=D0=B8=D0=BD=20=D0=9C=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D0=BC?= Date: Wed, 19 Oct 2022 09:59:21 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D0=B4=D0=B5=D1=8E=D1=81=D1=8C=20?= =?UTF-8?q?=D1=87=D1=82=D0=BE=20=D1=82=D0=BE=20=D0=BF=D0=BE=D0=BB=D1=83?= =?UTF-8?q?=D1=87=D0=B8=D1=82=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/modules.xml | 2 +- src/Direction.java | 10 ++++++---- src/DrawingField.java | 3 +-- src/DrawingGasolineTanker.java | 5 ++--- src/EntityGasolineTanker.java | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.idea/modules.xml b/.idea/modules.xml index aae69c9..661d1b8 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/src/Direction.java b/src/Direction.java index 5b70d63..5f50742 100644 --- a/src/Direction.java +++ b/src/Direction.java @@ -1,6 +1,8 @@ public enum Direction { - Up, - Down, - Left, - Right; + Up(1), + Down(2), + Left(3), + Right(4), + None(0); + Direction(int value){} } diff --git a/src/DrawingField.java b/src/DrawingField.java index 0fc63dd..94df9a6 100644 --- a/src/DrawingField.java +++ b/src/DrawingField.java @@ -42,8 +42,7 @@ public class DrawingField extends JPanel { } public void CreateButtonAction(){ Random rnd=new Random(); - _gasolineTanker=new DrawingGasolineTanker(); - _gasolineTanker.Init(rnd.nextInt(50)+10,rnd.nextInt(100)+500,new Color(rnd.nextInt(256),rnd.nextInt(256),rnd.nextInt(256))); + _gasolineTanker=new DrawingGasolineTanker(rnd.nextInt(50)+10,rnd.nextInt(100)+500,new Color(rnd.nextInt(256),rnd.nextInt(256),rnd.nextInt(256))); _gasolineTanker.SetPosition(rnd.nextInt(100)+10,rnd.nextInt(100)+10,getWidth(),getHeight()); field.SpeedLabel.setText("Speed: "+_gasolineTanker.getGasolineTanker().getSpeed()); field.WeightLabel.setText("Weight: "+_gasolineTanker.getGasolineTanker().getWeight()); diff --git a/src/DrawingGasolineTanker.java b/src/DrawingGasolineTanker.java index 8169677..f7f3bb9 100644 --- a/src/DrawingGasolineTanker.java +++ b/src/DrawingGasolineTanker.java @@ -13,10 +13,9 @@ public class DrawingGasolineTanker { private final int _gasolineTankerWidth = 160; private final int _gasolineTankerHeight = 55; - public void Init(int speed, float weight, Color bodyColor) + public DrawingGasolineTanker(int speed, float weight, Color bodyColor) { - GasolineTanker = new EntityGasolineTanker(); - GasolineTanker.Init(speed, weight, bodyColor); + GasolineTanker = new EntityGasolineTanker(speed, weight, bodyColor); Wheels = new DrawingWheels(); Wheels.SetCountWheels((int)(2 + Math.random() + Math.random()*2)); } diff --git a/src/EntityGasolineTanker.java b/src/EntityGasolineTanker.java index bb890d8..b881fb0 100644 --- a/src/EntityGasolineTanker.java +++ b/src/EntityGasolineTanker.java @@ -16,7 +16,7 @@ public class EntityGasolineTanker { } public float Step; - public void Init(int speed, float weight, Color bodyColor){ + public EntityGasolineTanker(int speed, float weight, Color bodyColor){ Random rnd = new Random(); Speed = speed <= 0 ? rnd.nextInt(50)+10 : speed;