did isLoopingBorder and toggleLoopingBorder, started gridCreation but

gotta finish
This commit is contained in:
Timéo 2024-05-07 17:26:16 +02:00
parent 5ad318256d
commit a5e35fdf31
1 changed files with 25 additions and 8 deletions

View File

@ -1,6 +1,8 @@
package backend; package backend;
import java.util.ArrayList; import java.util.ArrayList;
import managementImage.ImageColor;
import students.Gradient;
import windowInterface.MyInterface; import windowInterface.MyInterface;
public class Simulator extends Thread { public class Simulator extends Thread {
@ -24,6 +26,7 @@ public class Simulator extends Thread {
private boolean loopingBorder; private boolean loopingBorder;
private boolean clickActionFlag; private boolean clickActionFlag;
private int loopDelay = 150; private int loopDelay = 150;
private int[][] grid;
//TODO : add missing attribute(s) //TODO : add missing attribute(s)
@ -37,10 +40,10 @@ public class Simulator extends Thread {
agents = new ArrayList<Agent>(); agents = new ArrayList<Agent>();
fieldBirthValues = new ArrayList<Integer>(); fieldBirthValues = new ArrayList<Integer>();
fieldSurviveValues = new ArrayList<Integer>(); fieldSurviveValues = new ArrayList<Integer>();
cellState = false;
//TODO : add missing attribute initialization //TODO : add missing attribute initialization
grid = gridCreation();
//Default rule : Survive always, birth never //Default rule : Survive always, birth never
for(int i =0; i<9; i++) { for(int i =0; i<9; i++) {
@ -48,6 +51,18 @@ public class Simulator extends Thread {
} }
} }
public int[][] gridCreation() {
int[][] newGrid = new int[COL_NUM][LINE_NUM];
for (int x = 0; x < COL_NUM; x ++) {
for (int y = 0; y < LINE_NUM; y ++) {
//TODO set cell values
}
}
return newGrid;
}
public int getWidth() { public int getWidth() {
return COL_NUM; return COL_NUM;
@ -151,7 +166,7 @@ public class Simulator extends Thread {
* @return value of cell * @return value of cell
*/ */
public int getCell(int x, int y) { public int getCell(int x, int y) {
//TODO : complete method with proper return //get the value (dead or alive) of my cell at x y
return 0; return 0;
} }
/** /**
@ -250,13 +265,15 @@ public class Simulator extends Thread {
} }
public boolean isLoopingBorder() { public boolean isLoopingBorder() {
//TODO : complete method with proper return return loopingBorder;
return false; }
}
public void toggleLoopingBorder() { public void toggleLoopingBorder() {
//TODO : complete method if (loopingBorder){
loopingBorder = false;
}else {
loopingBorder = true;
}
} }
public void setLoopDelay(int delay) { public void setLoopDelay(int delay) {