summaryrefslogtreecommitdiffstats
path: root/šola/p1/dn/7/Blok.java
diff options
context:
space:
mode:
Diffstat (limited to 'šola/p1/dn/7/Blok.java')
-rw-r--r--šola/p1/dn/7/Blok.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/šola/p1/dn/7/Blok.java b/šola/p1/dn/7/Blok.java
new file mode 100644
index 0000000..2ac1863
--- /dev/null
+++ b/šola/p1/dn/7/Blok.java
@@ -0,0 +1,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;
+ }
+}