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;