summaryrefslogtreecommitdiffstats
path: root/šola/p1/dn/7/Blok.java
blob: 2ac18637b7cc52ba40dcca56c1cea6f6ed461f04 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.*;
public class Blok {
	private Stanovanje stanovanje;
	public Blok(Stanovanje stanovanje) {
		this.stanovanje = stanovanje;
	}
	public Oseba starosta() {
		return this.stanovanje.starostaSosescine();
	}
	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[maxx-minx+1][maxy-miny+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[tuple[1]-minx][tuple[2]-miny] = tuple[0]; // TODO think again
		return r;
	}
}