antihype commit 3.0

This commit is contained in:
antoc0der 2023-11-10 09:57:08 +03:00
parent 82bad5c255
commit 48bd006597
2 changed files with 14 additions and 20 deletions

View File

@ -7,44 +7,39 @@ import src.Entities.EntityAirplane;
import java.util.Random;
public class HardGeneric <T extends EntityAirplane,U extends IDraw>{
T[] arrFirst;
U[] arrSecond;
T[] arrAirplanes;
U[] arrIlluminators;
private int curSz;
private int CountFirst;
private int CountSecond;
private int pictureBoxWidth;
private int pictureBoxHeight;
public HardGeneric(int countFirst, int countSecond, int width, int height){
curSz = 0;
CountFirst = countFirst;
CountSecond = countSecond;
arrFirst = (T[]) new EntityAirplane[CountFirst];
arrSecond = (U[]) new IDraw[CountSecond];
arrAirplanes = (T[]) new EntityAirplane[CountFirst];
arrIlluminators = (U[]) new IDraw[CountSecond];
pictureBoxHeight = height;
pictureBoxWidth = width;
}
public int InsertFirst(T entityMonorail){
if(arrFirst[CountFirst-1] != null)
public int InsertFirst(T entityAirplane){
if(arrAirplanes[CountFirst-1] != null)
return -1;
for(int i = curSz -1; i>= 0; i--) {
arrFirst[i + 1] = arrFirst[i];
arrSecond[i + 1] = arrSecond[i];
arrAirplanes[i + 1] = arrAirplanes[i];
arrIlluminators[i + 1] = arrIlluminators[i];
}
curSz++;
arrFirst[0] = entityMonorail;
arrAirplanes[0] = entityAirplane;
return 0;
}
public int InsertSecond(U inter){
if(arrSecond[CountSecond-1] != null)
if(arrIlluminators[CountSecond-1] != null)
return -1;
arrSecond[0] = inter;
arrIlluminators[0] = inter;
return 0;
}
@ -52,8 +47,8 @@ public class HardGeneric <T extends EntityAirplane,U extends IDraw>{
Random rand = new Random();
int indFirst = rand.nextInt(0, curSz);
int indSecond = rand.nextInt(0,curSz);
EntityAirplane entity = arrFirst[indFirst];
IDraw inter = arrSecond[indSecond];
EntityAirplane entity = arrAirplanes[indFirst];
IDraw inter = arrIlluminators[indSecond];
DrawningAirplane airplane = new DrawningAirplane(entity.Speed(), entity.Weight(), entity.BodyColor(),
pictureBoxWidth, pictureBoxHeight);
return airplane;

View File

@ -14,7 +14,6 @@ import javax.swing.*;
public class Main {
public static void main(String[] args) throws IOException {
FormAirplaneCollection form =new FormAirplaneCollection();
//FormForHard form = new FormForHard();
FormForHard form = new FormForHard();
}
}