save agents works
This commit is contained in:
parent
e785ba1cf8
commit
aff82d0e8a
|
|
@ -0,0 +1,2 @@
|
|||
52,28;25,33;54,60;70,39;36,41
|
||||
27,27;62,48;38,63;23,39;74,74
|
||||
|
|
|
@ -649,13 +649,17 @@ public class Simulator extends Thread {
|
|||
//iterate through the agents arraylist
|
||||
for(Agent agent : agents){
|
||||
if(agent instanceof Sheep) {
|
||||
listSheep = listSheep + agent.getX() + "," + agent.getY() + ";";
|
||||
if (listSheep != "") listSheep = listSheep + ";";
|
||||
listSheep = listSheep + agent.getX() + "," + agent.getY();
|
||||
}else if (agent instanceof Wolf) {
|
||||
listWolf = listWolf + agent.getX() + "," + agent.getY() + ";";
|
||||
if (listWolf != "") listWolf = listWolf + ";";
|
||||
listWolf = listWolf + agent.getX() + "," + agent.getY();
|
||||
}
|
||||
}
|
||||
agentSave.add(listSheep);
|
||||
System.out.println("listSheep: " + listSheep);
|
||||
agentSave.add(listWolf);
|
||||
System.out.println("listWolf: " + listWolf);
|
||||
return agentSave;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -363,7 +363,7 @@ public class MyInterface extends JFrame {
|
|||
String fileName=SelectFile();
|
||||
if (fileName.length()>0) {
|
||||
ArrayList<String> content = mySimu.getAgentsSave();
|
||||
writeFile(fileName, (String[]) content.toArray());
|
||||
writeFile(fileName, content.toArray(new String[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue