summaryrefslogtreecommitdiffstats
path: root/šola/p1/dn/7/Blok.java
blob: a646dc9513d1cd98599f8e6bd1188fb49154a76c (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
34
35
36
37
38
39
40
41
42
43
44
45
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;
	}
}