worked on step

This commit is contained in:
Guillaume BONABAU 2024-04-10 16:04:09 +02:00
parent 5d3f8c8ab0
commit 20d4ba1a0f
2 changed files with 15 additions and 4 deletions

View File

@ -15,10 +15,10 @@ public class Cell {
public int getDensity() {
return density;
}
public int setValue(int value) {
public void setValue(int value) {
this.value = value;
}
public int setDensity(int density){
public void setDensity(int density){
this.density = density;
}
}

View File

@ -116,11 +116,22 @@ public class Simulator extends Thread {
Table tempTable = new Table(this.height, this.width);
for(int x=0; x<width; x++) {
for(int y=0; y<height; y++) {
if (table.countNear(x,y)<2) {
tempTable.getCell(x,y).setValue(0);
if (this.table.getCell(x, y).getValue()=1) {
if (table.countNear(x,y)<2) {
tempTable.getCell(x,y).setValue(0);
} else if(table.countNear(x,y)>3) {
tempTable.getCell(x,y).setValue(0);
}
} else {
if(table.countNear(x,y)==3) {
tempTable.getCell(x,y).setValue(1);
}
}
}
}
this.table = tempTable;
/* you should distribute this action in methods/classes
* don't write everything here !