Final Commit for School. More cool stuf after this commit.
This commit is contained in:
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,16 +8,14 @@ import java.util.TimerTask;
|
|||||||
public class Clock extends Thread {
|
public class Clock extends Thread {
|
||||||
|
|
||||||
private Control control;
|
private Control control;
|
||||||
private GUI gui;
|
|
||||||
private boolean running = true;
|
private boolean running = true;
|
||||||
private int velocity, delay;
|
private int velocity, delay;
|
||||||
private boolean isFirstGen;
|
private boolean isFirstGen;
|
||||||
private Timer t;
|
private Timer t;
|
||||||
private TimerTask tt;
|
private TimerTask tt;
|
||||||
|
|
||||||
public Clock(Control control, GUI gui) {
|
public Clock(Control control) {
|
||||||
this.control = control;
|
this.control = control;
|
||||||
this.gui = gui;
|
|
||||||
this.velocity = 500;
|
this.velocity = 500;
|
||||||
this.delay = 0;
|
this.delay = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class Control {
|
|||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
|
|
||||||
clock = new Clock(this, gui);
|
clock = new Clock(this);
|
||||||
gui = new GUI(this);
|
gui = new GUI(this);
|
||||||
readDAO = new ReadDAO();
|
readDAO = new ReadDAO();
|
||||||
writeDAO = new WriteDAO();
|
writeDAO = new WriteDAO();
|
||||||
|
|||||||
Reference in New Issue
Block a user