bunch of things - TOFIX: interface changes it full color for some reason

This commit is contained in:
Guillaume BONABAU 2024-04-26 10:02:03 +02:00
parent 630ab51514
commit 60c428fe64
2 changed files with 16 additions and 18 deletions

View File

@ -206,9 +206,9 @@ public class Simulator extends Thread {
* @return value of cell
*/
public int getCell(int x, int y) {
//TODO-ERROR : WHY THE FUCK DOES IT WORK AT 0 BUT NOT WITH table.getcell.getvalue ????
//TODO-INPROGRESS :
//complete method with proper return
return 0;
return this.table.getCell(x,y).getValue();
}
/**
*
@ -244,7 +244,12 @@ public class Simulator extends Thread {
public void setCell(int x, int y, int val) {
//TODO : complete method
//j'ai ajouté une base, mais manque la partie qui modifie la valeur de la cellule
int currentCellValue = getCell(x, y);
int currentCellValue = this.getCell(x, y);
if (currentCellValue==0) {
this.table.getCell(x, y).setValue(1);
}else {
this.table.getCell(x, y).setValue(0);
}
// set cell value to !currentCellValue
}
@ -252,12 +257,7 @@ public class Simulator extends Thread {
//enableLogs
//getCell
//if loopingBorder TRUE, border count as living.
if (loopingBorder == true){
}
else {
}
this.table.countNear(x, y);
}
@ -311,14 +311,7 @@ public class Simulator extends Thread {
* to be alive in new state
*/
public void generateRandom(float chanceOfLife) {
//TODO : complete method
/*
* Advice :
* as you should probably have a separate class
* representing the field of cells...
* maybe just make a constructor in there
* and use it here
*/
this.table.setRandom(chanceOfLife);
}
public boolean isLoopingBorder() {

View File

@ -64,9 +64,13 @@ public class Table {
for (int i = row-1;i<=row+1;i++){
for (int j = column-1;j<=column+1;column++){
if (!(i == j)){
if (i<0 || i>=width || j<0 || j>=height){
//TODO what to do when out of bound (wall alive or dead/ looping border) (wall dead by default)
} else {
cellCount += this.getCell(i,j).getValue();
}
}
}
}
return cellCount;
@ -87,6 +91,7 @@ public class Table {
}
}
}
System.out.println("Created a random field");
}
//TODO : load(filepath) turn a loaded saveable file into a table