Поправки в генерации
This commit is contained in:
parent
b208126772
commit
6f7f3302c1
@ -11,12 +11,12 @@ public class DrawingRoadTrain extends DrawingTruck{
|
|||||||
super(speed, weight, bodyColor, width, height, wheelNumber);
|
super(speed, weight, bodyColor, width, height, wheelNumber);
|
||||||
if (entityTruck != null)
|
if (entityTruck != null)
|
||||||
{
|
{
|
||||||
entityTruck = new EntityRoadTrain(speed, weight, bodyColor,
|
entityTruck = new EntityRoadTrain(speed, weight, bodyColor, wheelNumber,
|
||||||
additionalColor, waterContainer, sweepingBrush);
|
additionalColor, waterContainer, sweepingBrush);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public DrawingRoadTrain(EntityRoadTrain truck, IDrawingWheels _wheelDrawing, int width, int height, int wheelNumber ){
|
public DrawingRoadTrain(EntityRoadTrain truck, IDrawingWheels _wheelDrawing, int width, int height ){
|
||||||
super(truck, _wheelDrawing, width, height, wheelNumber);
|
super(truck, _wheelDrawing, width, height);
|
||||||
if (height < _truckHeight || width < _truckWidth)
|
if (height < _truckHeight || width < _truckWidth)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -32,14 +32,14 @@ public class DrawingTruck {
|
|||||||
}
|
}
|
||||||
protected int _truckWidth = 80;
|
protected int _truckWidth = 80;
|
||||||
protected int _truckHeight = 70;
|
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)
|
if (height < _truckHeight || width < _truckWidth)
|
||||||
return;
|
return;
|
||||||
_pictureWidth = width;
|
_pictureWidth = width;
|
||||||
_pictureHeight = height;
|
_pictureHeight = height;
|
||||||
entityTruck = truck;
|
entityTruck = truck;
|
||||||
drawingWheels = _wheelDrawing;
|
drawingWheels = _wheelDrawing;
|
||||||
drawingWheels.SetWheelNumber(wheelNumber);
|
drawingWheels.SetWheelNumber(entityTruck.Numwheel);
|
||||||
}
|
}
|
||||||
public DrawingTruck(int speed, double weight, Color mainColor, int width, int height, int wheelNumber) {
|
public DrawingTruck(int speed, double weight, Color mainColor, int width, int height, int wheelNumber) {
|
||||||
if (width < _truckWidth || height < _truckHeight) {
|
if (width < _truckWidth || height < _truckHeight) {
|
||||||
@ -47,7 +47,7 @@ public class DrawingTruck {
|
|||||||
}
|
}
|
||||||
_pictureWidth = width;
|
_pictureWidth = width;
|
||||||
_pictureHeight = height;
|
_pictureHeight = height;
|
||||||
entityTruck = new EntityTruck(speed, weight, mainColor);
|
entityTruck = new EntityTruck(speed, weight, mainColor, wheelNumber);
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
drawingWheels = switch (rand.nextInt(0, 3)) {
|
drawingWheels = switch (rand.nextInt(0, 3)) {
|
||||||
case 0 -> new DrawingWheels();
|
case 0 -> new DrawingWheels();
|
||||||
@ -67,7 +67,7 @@ public class DrawingTruck {
|
|||||||
_pictureHeight = height;
|
_pictureHeight = height;
|
||||||
_truckWidth = truckWidth;
|
_truckWidth = truckWidth;
|
||||||
_truckHeight = truckHeight;
|
_truckHeight = truckHeight;
|
||||||
entityTruck = new EntityTruck(speed, weight, mainColor);
|
entityTruck = new EntityTruck(speed, weight, mainColor, wheelNumber);
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
drawingWheels = switch (rand.nextInt(0, 3)) {
|
drawingWheels = switch (rand.nextInt(0, 3)) {
|
||||||
case 0 -> new DrawingWheels();
|
case 0 -> new DrawingWheels();
|
||||||
|
@ -12,9 +12,9 @@ public class EntityRoadTrain extends EntityTruck {
|
|||||||
return SweepingBrush;
|
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) {
|
additionalColor, boolean waterContainer, boolean sweepingBrush) {
|
||||||
super(speed, weight, bodyColor);
|
super(speed, weight, bodyColor, numwheel);
|
||||||
AdditionalColor = additionalColor;
|
AdditionalColor = additionalColor;
|
||||||
WaterContainer = waterContainer;
|
WaterContainer = waterContainer;
|
||||||
SweepingBrush = sweepingBrush;
|
SweepingBrush = sweepingBrush;
|
||||||
|
@ -18,14 +18,16 @@ public class EntityTruck {
|
|||||||
public Color GetBodyColor() {
|
public Color GetBodyColor() {
|
||||||
return BodyColor;
|
return BodyColor;
|
||||||
}
|
}
|
||||||
|
public int Numwheel;
|
||||||
|
|
||||||
public double GetStep() {
|
public double GetStep() {
|
||||||
return (double) Speed * 100 / Weight;
|
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;
|
Speed = speed;
|
||||||
Weight = weight;
|
Weight = weight;
|
||||||
BodyColor = bodyColor;
|
BodyColor = bodyColor;
|
||||||
|
Numwheel = numwheel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,10 +61,10 @@ public class GenericDopClass<T extends EntityTruck, U extends IDrawingWheels> {
|
|||||||
}
|
}
|
||||||
DrawingTruck drawingTruck;
|
DrawingTruck drawingTruck;
|
||||||
if (truck instanceof EntityRoadTrain){
|
if (truck instanceof EntityRoadTrain){
|
||||||
drawingTruck = new DrawingRoadTrain((EntityRoadTrain)truck, wheel, _pictureWidth, _pictureHeight, random.nextInt(3));
|
drawingTruck = new DrawingRoadTrain((EntityRoadTrain)truck, wheel, _pictureWidth, _pictureHeight);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
drawingTruck = new DrawingTruck(truck, wheel, _pictureWidth, _pictureHeight, random.nextInt(3));
|
drawingTruck = new DrawingTruck(truck, wheel, _pictureWidth, _pictureHeight);
|
||||||
}
|
}
|
||||||
return drawingTruck;
|
return drawingTruck;
|
||||||
}
|
}
|
||||||
|
@ -40,10 +40,10 @@ public class FormGenericDopClass extends JFrame {
|
|||||||
canv.setBounds(0,0,pictureBoxWidth, pictureBoxHeight);
|
canv.setBounds(0,0,pictureBoxWidth, pictureBoxHeight);
|
||||||
|
|
||||||
genericDopClass = new GenericDopClass<>(100, 100, pictureBoxWidth, pictureBoxHeight);
|
genericDopClass = new GenericDopClass<>(100, 100, pictureBoxWidth, pictureBoxHeight);
|
||||||
genericDopClass.add(new EntityTruck(100, 100, Color.BLUE));
|
genericDopClass.add(new EntityTruck(100, 100, Color.BLUE, 1));
|
||||||
genericDopClass.add(new EntityTruck(100, 100, Color.RED));
|
genericDopClass.add(new EntityTruck(100, 100, Color.RED, 2));
|
||||||
genericDopClass.add(new EntityTruck(100, 100, Color.GRAY));
|
genericDopClass.add(new EntityTruck(100, 100, Color.GRAY, 1));
|
||||||
genericDopClass.add(new EntityRoadTrain(100, 100, Color.BLUE, Color.ORANGE, true, true));
|
genericDopClass.add(new EntityRoadTrain(100, 100, Color.BLUE, 3, Color.ORANGE, true, true));
|
||||||
genericDopClass.add(new DrawingOneLineWheels());
|
genericDopClass.add(new DrawingOneLineWheels());
|
||||||
genericDopClass.add(new DrawingTwoLineWheels());
|
genericDopClass.add(new DrawingTwoLineWheels());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user