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

View File

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