From 6f7f3302c1312f940cc618f23c4c505262c573f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D0=B8=D0=BB=20=D0=9F=D1=83=D1=82?= =?UTF-8?q?=D0=B8=D0=BD=D1=86=D0=B5=D0=B2?= Date: Sat, 25 Nov 2023 00:19:05 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=B2=20=D0=B3=D0=B5=D0=BD=D0=B5=D1=80=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/RoadTrain/DrawingObjects/DrawingRoadTrain.java | 6 +++--- src/RoadTrain/DrawingObjects/DrawingTruck.java | 8 ++++---- src/RoadTrain/Entities/EntityRoadTrain.java | 4 ++-- src/RoadTrain/Entities/EntityTruck.java | 4 +++- src/RoadTrain/Extra/GenericDopClass.java | 4 ++-- src/RoadTrain/FormGenericDopClass.java | 8 ++++---- 6 files changed, 18 insertions(+), 16 deletions(-) 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());