diff --git a/Utils.java b/Utils.java index fbc668a..fe3cd3c 100644 --- a/Utils.java +++ b/Utils.java @@ -1,6 +1,7 @@ import greenfoot.*; import java.awt.Color; import java.util.*; +import java.lang.Object; /** Diese Klasse enthält nur statische Funktionen, welche für euch als Unterstützung gedacht sind. Damit könnt ihr dann hoffentlich viele Code-Zeilen sparen. :) @@ -82,4 +83,24 @@ public final class Utils { } catch (java.lang.NumberFormatException e) {} return i; } + + public static Province[] cutArray(Province[] obA) { + boolean[] l = new boolean[obA.length]; + int c = 0; + for(int i = 0; i < obA.length; i++) { + if(obA[i] != null) { + l[i] = true; + c++; + } + } + int p = 0; + Province[] ret = new Province[c]; + for(int i = 0; i < l.length; i++) { + if(l[i]) { + ret[p] = obA[i]; + p++; + } + } + return ret; + } }