import java.util.*; public class Blok { public Stanovanje stanovanje; public Blok(Stanovanje stanovanje) { this.stanovanje = stanovanje; } public Oseba starosta() { Oseba r = null; for (Oseba[] os : this.stanovanje.staroste()) { if (os[0] == null) continue; if (r == null) { r = os[0]; continue; } if (os[0].jeStarejsaOd(r)) r = os[0]; } return r; } public int[][] razporeditev() { int minx = Integer.MAX_VALUE; int maxx = Integer.MIN_VALUE; int miny = Integer.MAX_VALUE; int maxy = Integer.MIN_VALUE; for (int[] tuple : stanovanje.pozicije()) { if (tuple[1] > maxx) maxx = tuple[1]; if (tuple[2] > maxy) maxy = tuple[2]; if (tuple[1] < minx) minx = tuple[1]; if (tuple[2] < miny) miny = tuple[2]; } int[][] r = new int[maxy-miny+1][maxx-minx+1]; for (int i = 0; i < r.length; i++) for (int j = 0; j < r[i].length; j++) r[i][j] = -1; for (int[] tuple : stanovanje.pozicije()) r[maxy-miny-(tuple[2]-miny)][tuple[1]-minx] = tuple[0]; // TODO think again return r; } }