Add comment to enginner class and leadAgents
This commit is contained in:
parent
276727eb63
commit
b47afab147
|
|
@ -372,23 +372,27 @@ public class Simulator extends Thread {
|
|||
}
|
||||
return agentSave;
|
||||
}
|
||||
|
||||
|
||||
public void loadAgents(ArrayList<String> stringArray) {
|
||||
//collect the information(type, coordate) of each agent
|
||||
for(int i =0; i<stringArray.size();i++) {
|
||||
String agentLine = stringArray.get(i);
|
||||
String[] agentElements = agentLine.split(";");
|
||||
int[] agentValues = new int[3];
|
||||
//convert string to integer and separate in a matrix
|
||||
for(int j=0; j<agentElements.length;j++) {
|
||||
agentValues[j] = Integer.parseInt(agentElements[j]);
|
||||
}
|
||||
//get the type of the agent
|
||||
// create a sheep
|
||||
if (agentValues[2] == 1){
|
||||
agents.add(new Sheep(agentValues[0],agentValues[1]));
|
||||
}
|
||||
//create an engineer
|
||||
if (agentValues[2] == 2){
|
||||
agents.add(new Engineer(agentValues[0],agentValues[1]));
|
||||
}
|
||||
}
|
||||
//TODO : Same idea as other load methods, but for agent list
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue