fix object
This commit is contained in:
parent
66f961be08
commit
2035ffd79d
@ -1,24 +1,25 @@
|
||||
import java.util.Random;
|
||||
import java.util.ArrayList;
|
||||
public class CreaterGeneric <T extends EntityGasolineTanker, U extends IDrawningObjectWheels>{
|
||||
Object[] GasolineTanker;
|
||||
Object[] Wheels;
|
||||
ArrayList<T> GasolineTanker;
|
||||
ArrayList<U> Wheels;
|
||||
int GasolineTankerCount=0;
|
||||
int WheelsCount=0;
|
||||
public CreaterGeneric(int gasolineTankerCount,int wheelsCount){
|
||||
GasolineTanker=new Object[gasolineTankerCount];
|
||||
Wheels=new Object[wheelsCount];
|
||||
GasolineTanker=new ArrayList<>(gasolineTankerCount);
|
||||
Wheels=new ArrayList<>(wheelsCount);
|
||||
}
|
||||
public int AddGasolineTanker(T gasolineTanker){
|
||||
if(GasolineTankerCount<GasolineTanker.length){
|
||||
GasolineTanker[GasolineTankerCount]=gasolineTanker;
|
||||
if(GasolineTankerCount<=GasolineTanker.size()){
|
||||
GasolineTanker.add(gasolineTanker);
|
||||
GasolineTankerCount++;
|
||||
return GasolineTankerCount-1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public int AddWheels(U wheels){
|
||||
if(WheelsCount<Wheels.length){
|
||||
Wheels[WheelsCount]=wheels;
|
||||
if(WheelsCount<=Wheels.size()){
|
||||
Wheels.add(wheels);
|
||||
WheelsCount++;
|
||||
return WheelsCount-1;
|
||||
}
|
||||
@ -27,8 +28,8 @@ public class CreaterGeneric <T extends EntityGasolineTanker, U extends IDrawning
|
||||
public DrawingGasolineTanker NewGasolineTankerCreating()
|
||||
{
|
||||
Random rand=new Random();
|
||||
T gasolineTanker = (T)GasolineTanker[rand.nextInt(GasolineTankerCount)];
|
||||
U wheel = (U)Wheels[rand.nextInt(WheelsCount)];
|
||||
T gasolineTanker = (GasolineTanker.get(rand.nextInt(GasolineTankerCount)));
|
||||
U wheel = (Wheels.get(rand.nextInt(WheelsCount)));
|
||||
if(gasolineTanker instanceof EntityImprovedGasolineTanker){
|
||||
return new DrawingImprovedGasolineTanker(gasolineTanker,wheel);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user