diff --git a/src/backend/Agent.java b/src/backend/Agent.java index 9eeef1e..b5c48ee 100644 --- a/src/backend/Agent.java +++ b/src/backend/Agent.java @@ -23,6 +23,17 @@ public abstract class Agent { public int getY() { return y; } +//presence of an agent at those coordinates + public boolean agentPresence(int x, int y){ + + if (this.getX() == x && this.getY() == y) { + return true; + } + else { + return false; + } + } + public boolean isInArea(int x, int y, int radius) { int diffX = this.x-x; int diffY = this.y-y; diff --git a/src/backend/Cell.java b/src/backend/Cell.java index 73a136f..8151c46 100644 --- a/src/backend/Cell.java +++ b/src/backend/Cell.java @@ -3,7 +3,6 @@ package backend; public class Cell { private int value; - public Cell(int value) { this.value = value; } @@ -12,12 +11,7 @@ public class Cell { return value; } - - public void setValue(int value) { this.value = value; } - - - } diff --git a/src/backend/Simulator.java b/src/backend/Simulator.java index 7b4ff54..f767b0d 100644 --- a/src/backend/Simulator.java +++ b/src/backend/Simulator.java @@ -1,4 +1,5 @@ package backend; +import java.awt.Color; import java.util.ArrayList; import windowInterface.MyInterface; @@ -448,7 +449,7 @@ public class Simulator extends Thread { * @return String representation of click action */ public String clickActionName() { - // TODO : initially return "sheep" or "cell" + // TODO-COMPLETE : initially return "sheep" or "cell" // depending on clickActionFlag if (clickActionFlag){ return "cell"; @@ -458,4 +459,47 @@ public class Simulator extends Thread { } } + //TODO-INPROGRESS : set agent (x y agent) load an agent to coordinates x,y + public void setSheep(int x,int y){ + Sheep sheep = new Sheep(x,y); + agents.add(sheep); + printAgents(); + } + +//method for clickAgent first setup to spawn sheeps + public void clickAgent(int x, int y) { + if (clickActionFlag == false) { + Sheep sheep = new Sheep(x,y); + + this.setSheep(x,y); + //process to check if there is already an agent (removes the agent if clicking on it) + //if (agentPresence(x,y) == true) { + + + //} + + + if (enableLogs) { + System.out.println("clickAgent Called, Agent spawned at coordinates:" + x + "," + y + ""); + } + + + } + else { + return; + } + } + public void printAgents() { + for (Agent agent : agents) { + String agentType = agent.getClass().getSimpleName(); + int x = agent.getX(); + int y = agent.getY(); + Color color = agent.getDisplayColor(); + + System.out.println("Agent Type: " + agentType); + System.out.println("Position: (" + x + ", " + y + ")"); + System.out.println("Color: " + color); + System.out.println(); + } + } } diff --git a/src/backend/Table.java b/src/backend/Table.java index 878f86b..8d17373 100644 --- a/src/backend/Table.java +++ b/src/backend/Table.java @@ -90,7 +90,6 @@ public class Table { } - //TODO : set agent (x y agent) load an agent to coordinates x,y //TODO : set random (density) create a random table of determined density public void setRandom(double density) {