diff --git a/src/RoadTrain/DrawingObjects/DrawingRoadTrain.java b/src/RoadTrain/DrawingObjects/DrawingRoadTrain.java index d9f4cf6..90df8f9 100644 --- a/src/RoadTrain/DrawingObjects/DrawingRoadTrain.java +++ b/src/RoadTrain/DrawingObjects/DrawingRoadTrain.java @@ -11,12 +11,12 @@ public class DrawingRoadTrain extends DrawingTruck{ super(speed, weight, bodyColor, width, height, wheelNumber); if (entityTruck != null) { - entityTruck = new EntityRoadTrain(speed, weight, bodyColor, + entityTruck = new EntityRoadTrain(speed, weight, bodyColor, wheelNumber, additionalColor, waterContainer, sweepingBrush); } } - public DrawingRoadTrain(EntityRoadTrain truck, IDrawingWheels _wheelDrawing, int width, int height, int wheelNumber ){ - super(truck, _wheelDrawing, width, height, wheelNumber); + public DrawingRoadTrain(EntityRoadTrain truck, IDrawingWheels _wheelDrawing, int width, int height ){ + super(truck, _wheelDrawing, width, height); if (height < _truckHeight || width < _truckWidth) return; } diff --git a/src/RoadTrain/DrawingObjects/DrawingTruck.java b/src/RoadTrain/DrawingObjects/DrawingTruck.java index 19bf6a4..b37d819 100644 --- a/src/RoadTrain/DrawingObjects/DrawingTruck.java +++ b/src/RoadTrain/DrawingObjects/DrawingTruck.java @@ -32,14 +32,14 @@ public class DrawingTruck { } protected int _truckWidth = 80; protected int _truckHeight = 70; - public DrawingTruck(EntityTruck truck, IDrawingWheels _wheelDrawing, int width, int height, int wheelNumber ){ + public DrawingTruck(EntityTruck truck, IDrawingWheels _wheelDrawing, int width, int height){ if (height < _truckHeight || width < _truckWidth) return; _pictureWidth = width; _pictureHeight = height; entityTruck = truck; drawingWheels = _wheelDrawing; - drawingWheels.SetWheelNumber(wheelNumber); + drawingWheels.SetWheelNumber(entityTruck.Numwheel); } public DrawingTruck(int speed, double weight, Color mainColor, int width, int height, int wheelNumber) { if (width < _truckWidth || height < _truckHeight) { @@ -47,7 +47,7 @@ public class DrawingTruck { } _pictureWidth = width; _pictureHeight = height; - entityTruck = new EntityTruck(speed, weight, mainColor); + entityTruck = new EntityTruck(speed, weight, mainColor, wheelNumber); Random rand = new Random(); drawingWheels = switch (rand.nextInt(0, 3)) { case 0 -> new DrawingWheels(); @@ -67,7 +67,7 @@ public class DrawingTruck { _pictureHeight = height; _truckWidth = truckWidth; _truckHeight = truckHeight; - entityTruck = new EntityTruck(speed, weight, mainColor); + entityTruck = new EntityTruck(speed, weight, mainColor, wheelNumber); Random rand = new Random(); drawingWheels = switch (rand.nextInt(0, 3)) { case 0 -> new DrawingWheels(); diff --git a/src/RoadTrain/Entities/EntityRoadTrain.java b/src/RoadTrain/Entities/EntityRoadTrain.java index 4272a88..4afa0e7 100644 --- a/src/RoadTrain/Entities/EntityRoadTrain.java +++ b/src/RoadTrain/Entities/EntityRoadTrain.java @@ -12,9 +12,9 @@ public class EntityRoadTrain extends EntityTruck { return SweepingBrush; } - public EntityRoadTrain(int speed, double weight, Color bodyColor, Color + public EntityRoadTrain(int speed, double weight, Color bodyColor, int numwheel, Color additionalColor, boolean waterContainer, boolean sweepingBrush) { - super(speed, weight, bodyColor); + super(speed, weight, bodyColor, numwheel); AdditionalColor = additionalColor; WaterContainer = waterContainer; SweepingBrush = sweepingBrush; diff --git a/src/RoadTrain/Entities/EntityTruck.java b/src/RoadTrain/Entities/EntityTruck.java index 5caad17..11dab35 100644 --- a/src/RoadTrain/Entities/EntityTruck.java +++ b/src/RoadTrain/Entities/EntityTruck.java @@ -18,14 +18,16 @@ public class EntityTruck { public Color GetBodyColor() { return BodyColor; } + public int Numwheel; public double GetStep() { return (double) Speed * 100 / Weight; } - public EntityTruck(int speed, double weight, Color bodyColor) { + public EntityTruck(int speed, double weight, Color bodyColor, int numwheel) { Speed = speed; Weight = weight; BodyColor = bodyColor; + Numwheel = numwheel; } } diff --git a/src/RoadTrain/Extra/GenericDopClass.java b/src/RoadTrain/Extra/GenericDopClass.java index 024429f..4b1c1e3 100644 --- a/src/RoadTrain/Extra/GenericDopClass.java +++ b/src/RoadTrain/Extra/GenericDopClass.java @@ -61,10 +61,10 @@ public class GenericDopClass { } DrawingTruck drawingTruck; if (truck instanceof EntityRoadTrain){ - drawingTruck = new DrawingRoadTrain((EntityRoadTrain)truck, wheel, _pictureWidth, _pictureHeight, random.nextInt(3)); + drawingTruck = new DrawingRoadTrain((EntityRoadTrain)truck, wheel, _pictureWidth, _pictureHeight); } else{ - drawingTruck = new DrawingTruck(truck, wheel, _pictureWidth, _pictureHeight, random.nextInt(3)); + drawingTruck = new DrawingTruck(truck, wheel, _pictureWidth, _pictureHeight); } return drawingTruck; } diff --git a/src/RoadTrain/FormGenericDopClass.java b/src/RoadTrain/FormGenericDopClass.java index f5a7f3c..7c34338 100644 --- a/src/RoadTrain/FormGenericDopClass.java +++ b/src/RoadTrain/FormGenericDopClass.java @@ -40,10 +40,10 @@ public class FormGenericDopClass extends JFrame { canv.setBounds(0,0,pictureBoxWidth, pictureBoxHeight); genericDopClass = new GenericDopClass<>(100, 100, pictureBoxWidth, pictureBoxHeight); - genericDopClass.add(new EntityTruck(100, 100, Color.BLUE)); - genericDopClass.add(new EntityTruck(100, 100, Color.RED)); - genericDopClass.add(new EntityTruck(100, 100, Color.GRAY)); - genericDopClass.add(new EntityRoadTrain(100, 100, Color.BLUE, Color.ORANGE, true, true)); + genericDopClass.add(new EntityTruck(100, 100, Color.BLUE, 1)); + genericDopClass.add(new EntityTruck(100, 100, Color.RED, 2)); + genericDopClass.add(new EntityTruck(100, 100, Color.GRAY, 1)); + genericDopClass.add(new EntityRoadTrain(100, 100, Color.BLUE, 3, Color.ORANGE, true, true)); genericDopClass.add(new DrawingOneLineWheels()); genericDopClass.add(new DrawingTwoLineWheels());