This commit is contained in:
titou 2024-05-27 16:01:12 +02:00
parent b378445958
commit 8df3e68325
1 changed files with 22 additions and 3 deletions

View File

@ -216,8 +216,17 @@ public class Simulator extends Thread {
*/
public ArrayList<String> getSaveState() {
//TODO : complete method with proper return
return null;
ArrayList<String> saveState = new ArrayList<>();
for (int y = 0; y<LINE_NUM; y++) {
StringBuilder line = new StringBuilder();
for (int x = 0; x<COL_NUM; x++) {
line.append(field[y][x]).append(";");
}
saveState.add(line.toString());
}
return saveState;
}
//DONE
/**
*
* @param lines of file representing saved world state
@ -305,8 +314,18 @@ public class Simulator extends Thread {
*/
public ArrayList<String> getRule() {
//TODO : complete method with proper return
return null;
ArrayList<String> rule = new ArrayList<>();
StringBuilder surviveLine = new StringBuilder();
for (Integer value : fieldSurviveValues) {
surviveLine.append(value).append(";");
}
StringBuilder birthLine = new StringBuilder();
for (Integer value : fieldBirthValues) {
birthLine.append(value).append(";");
}
rule.add(surviveLine.toString());
rule.add(birthLine.toString());
return rule;
}
public void loadRule(ArrayList<String> lines) {