Final Commit for School. More cool stuf after this commit.

This commit is contained in:
Noah
2021-12-13 21:03:25 +01:00
parent e8d56e5055
commit 73c247bfa2
3 changed files with 45 additions and 4 deletions
+43
View File
@@ -0,0 +1,43 @@
package database;
import java.util.ArrayList;
import java.util.List;
public class ArrayParser {
public String serialize(final boolean[][] grid) {
final StringBuilder erg = new StringBuilder();
for (boolean[] booleans : grid) {
for (boolean aBoolean : booleans) {
if (aBoolean) {
erg.append("1");
} else {
erg.append("0");
}
}
}
return erg.toString();
}
public boolean[][] deserialize(int width, int height, String string) {
boolean[][] erg = new boolean[height][width];
List<Integer> ints = new ArrayList<>();
for (String s : string.split("")) ints.add(Integer.parseInt(s));
int index = 0;
for (int y = 0; y < erg.length; y++) {
System.out.println(erg[y].length);
for (int x = 0; x < erg.length; x++) {
erg[y][x] = ints.get(index) == 1;
index++;
}
}
return erg;
}
}
+1 -3
View File
@@ -8,16 +8,14 @@ import java.util.TimerTask;
public class Clock extends Thread {
private Control control;
private GUI gui;
private boolean running = true;
private int velocity, delay;
private boolean isFirstGen;
private Timer t;
private TimerTask tt;
public Clock(Control control, GUI gui) {
public Clock(Control control) {
this.control = control;
this.gui = gui;
this.velocity = 500;
this.delay = 0;
+1 -1
View File
@@ -29,7 +29,7 @@ public class Control {
public void start() {
clock = new Clock(this, gui);
clock = new Clock(this);
gui = new GUI(this);
readDAO = new ReadDAO();
writeDAO = new WriteDAO();