Compare commits
No commits in common. "a6d1695a31c5c51cae73127004973ca5a30fd345" and "b96bc6dcad534d7d28cdb9cff869dfdc7c1d643c" have entirely different histories.
a6d1695a31
...
b96bc6dcad
@ -1,12 +1,11 @@
|
||||
package laba1Loco;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
public class GenericDopClass<T extends EntityTrain, U extends IWheelDrawing> {
|
||||
|
||||
private ArrayList<T> Trains;
|
||||
private ArrayList<U> Wheels;
|
||||
private Object[] Trains;
|
||||
private Object[] Wheels;
|
||||
private int maxCountTrains;
|
||||
private int countTrains;
|
||||
private int maxCountWheels;
|
||||
@ -24,8 +23,8 @@ public class GenericDopClass<T extends EntityTrain, U extends IWheelDrawing> {
|
||||
public GenericDopClass(int _maxCountTrains, int _maxCountWheels, int pictureWidth, int pictureHeight){
|
||||
maxCountTrains = _maxCountTrains;
|
||||
maxCountWheels = _maxCountWheels;
|
||||
Trains = new ArrayList<T>(maxCountTrains);
|
||||
Wheels = new ArrayList<U>(maxCountWheels);
|
||||
Trains = new Object[maxCountTrains];
|
||||
Wheels = new Object[maxCountWheels];
|
||||
countTrains = 0;
|
||||
countWheels = 0;
|
||||
_pictureWidth = pictureWidth;
|
||||
@ -38,7 +37,7 @@ public class GenericDopClass<T extends EntityTrain, U extends IWheelDrawing> {
|
||||
return false;
|
||||
if (countTrains > maxCountTrains)
|
||||
return false;
|
||||
Trains.add(countTrains++, train);
|
||||
Trains[countTrains++] = train;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -47,7 +46,7 @@ public class GenericDopClass<T extends EntityTrain, U extends IWheelDrawing> {
|
||||
return false;
|
||||
if (countWheels > maxCountWheels)
|
||||
return false;
|
||||
Wheels.add(countWheels++, wheel);
|
||||
Wheels[countWheels++] = wheel;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -57,11 +56,11 @@ public class GenericDopClass<T extends EntityTrain, U extends IWheelDrawing> {
|
||||
int i = random.nextInt(countTrains);
|
||||
int j = random.nextInt(countWheels);
|
||||
DrawingTrain drawingTrain;
|
||||
if (Trains.get(i) instanceof EntityLoco){
|
||||
drawingTrain = new DrawingLoco((EntityLoco)Trains.get(i), Wheels.get(j), _pictureWidth, _pictureHeight);
|
||||
if (Trains[i] instanceof EntityLoco){
|
||||
drawingTrain = new DrawingLoco((EntityLoco)Trains[i], (IWheelDrawing)Wheels[j], _pictureWidth, _pictureHeight);
|
||||
}
|
||||
else{
|
||||
drawingTrain = new DrawingTrain(Trains.get(i), Wheels.get(j), _pictureWidth, _pictureHeight);
|
||||
drawingTrain = new DrawingTrain((EntityTrain)Trains[i], (IWheelDrawing)Wheels[j], _pictureWidth, _pictureHeight);
|
||||
}
|
||||
return drawingTrain;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user