saveRule implementation
This commit is contained in:
parent
7ae1795911
commit
d3efcf8140
|
|
@ -476,8 +476,24 @@ public class Simulator extends Thread {
|
|||
*/
|
||||
public ArrayList<String> getRule() {
|
||||
//TODO : complete method with proper return
|
||||
|
||||
return null;
|
||||
ArrayList<String> arrayline=new ArrayList<String>();
|
||||
String lineOne="";
|
||||
for(int i=0;i<ruleSurviveCriteria.size();i++) {
|
||||
lineOne+=Integer.toString(ruleSurviveCriteria.get(i));
|
||||
if(i<ruleSurviveCriteria.size()-1) {
|
||||
lineOne+=";";
|
||||
}
|
||||
}
|
||||
arrayline.add(lineOne);
|
||||
String lineTwo="";
|
||||
for(int j=0;j<ruleBirthCriteria.size();j++) {
|
||||
lineTwo+=Integer.toString(ruleBirthCriteria.get(j));
|
||||
if(j<ruleBirthCriteria.size()-1) {
|
||||
lineTwo+=";";
|
||||
}
|
||||
}
|
||||
arrayline.add(lineTwo);
|
||||
return arrayline;
|
||||
}
|
||||
|
||||
public void loadRule(ArrayList<String> lines) {
|
||||
|
|
|
|||
|
|
@ -327,8 +327,7 @@ public class MyInterface extends JFrame {
|
|||
String fileName=SelectFile();
|
||||
if (fileName.length()>0) {
|
||||
ArrayList<String> content = mySimu.getSaveState();
|
||||
String[] strArr = Arrays.copyOf(content.toArray(), content.toArray().length, String[].class);
|
||||
writeFile(fileName, strArr);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -336,7 +335,8 @@ public class MyInterface extends JFrame {
|
|||
String fileName=SelectFile();
|
||||
if (fileName.length()>0) {
|
||||
ArrayList<String> content = mySimu.getRule();
|
||||
writeFile(fileName, (String[]) content.toArray());
|
||||
String[] strArr = Arrays.copyOf(content.toArray(), content.toArray().length, String[].class);
|
||||
writeFile(fileName, strArr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue