import java.util.Random; public class HardGeneric { T[] arrFirst; U[] arrSecond; 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 EntityCatamaran[CountFirst]; arrSecond = (U[]) new IDraw[CountSecond]; pictureBoxHeight = height; pictureBoxWidth = width; } public int InsertFirst(T entityCatamaran) { if (arrFirst[CountFirst - 1] != null) return -1; for (int i = curSz - 1; i >= 0; i--) { arrFirst[i + 1] = arrFirst[i]; arrSecond[i + 1] = arrSecond[i]; } curSz++; arrFirst[0] = entityCatamaran; return 0; } public int InsertSecond(U inter) { if (arrSecond[CountSecond - 1] != null) return -1; arrSecond[0] = inter; return 0; } public DrawningCatamaran MakeObject() { Random rand = new Random(); int indFirst = rand.nextInt(0, curSz); int indSecond = rand.nextInt(0, curSz); EntityCatamaran entity = arrFirst[indFirst]; IDraw inter = arrSecond[indSecond]; DrawningCatamaran catamaran = new DrawningCatamaran(entity.Speed(), entity.Weight(), entity.BodyColor(), entity.OarColor(), pictureBoxWidth, pictureBoxHeight, entity.BodyKit(), entity.Seats()); return catamaran; } }