diff --git a/src/backend/Sheep.java b/src/backend/Sheep.java index b62af02..3c0f302 100644 --- a/src/backend/Sheep.java +++ b/src/backend/Sheep.java @@ -29,7 +29,7 @@ public class Sheep extends Agent { * it can interact with the cells or with other animals * as you wish */ - public boolean liveTurn(ArrayList neighbors, Simulator world) { + public boolean liveTurn(ArrayList neighbors, World world) { if(world.getCell(x, y)==1) { world.setCell(x, y, 0); } else { diff --git a/src/backend/Simulator.java b/src/backend/Simulator.java index 4e5a183..50c8018 100644 --- a/src/backend/Simulator.java +++ b/src/backend/Simulator.java @@ -31,7 +31,7 @@ public class Simulator extends Thread { private boolean stopFlag; private boolean pauseFlag; private boolean loopingBorder; - private boolean clickActionFlag; + private int clickActionFlag; private int loopDelay = 150; private int[][] worldGrid; private World world; //get the World instance @@ -45,7 +45,7 @@ public class Simulator extends Thread { //stopFlag=false; //not necessary since i set the state when pressing the button start pauseFlag=false; loopingBorder=false; - clickActionFlag=false; + clickActionFlag=0; agents = new ArrayList(); fieldBirthValues = new ArrayList(); @@ -224,7 +224,13 @@ public class Simulator extends Thread { * method called when clicking on a cell in the interface */ public void clickCell(int x, int y) { - world.setCell(x, y, getCell(x, y) == 1 ? 0 : 1); + if (clickActionFlag==0) { + world.setCell(x, y, getCell(x, y) == 1 ? 0 : 1); + } else if (clickActionFlag==1) { + + } else if (clickActionFlag==2) { + + } } @@ -358,10 +364,11 @@ public class Simulator extends Thread { } public void toggleClickAction() { - if (clickActionFlag() != 2) { - = ++ + if (clickActionFlag < 2) { + clickActionFlag ++ ; + }else if (clickActionFlag == 2) { + clickActionFlag=0; } - else = 0 } @@ -385,7 +392,16 @@ public class Simulator extends Thread { public String clickActionName() { // TODO : initially return "sheep" or "cell" // depending on clickActionFlag - return ""; + + if (clickActionFlag==0) { + return "cell"; + }else if (clickActionFlag==1) { + return "sheep"; + }else if (clickActionFlag==2) { + return "wolf"; + }else { + return "error"; + } }