getRule
This commit is contained in:
parent
b378445958
commit
8df3e68325
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue