clickActionFlag add to clickCell
add setLoopDelay add toggleClickAction
This commit is contained in:
parent
b27ef8ffe0
commit
3c05da825f
|
|
@ -148,17 +148,21 @@ public class Simulator extends Thread {
|
||||||
* method called when clicking on a cell in the interface
|
* method called when clicking on a cell in the interface
|
||||||
*/
|
*/
|
||||||
public void clickCell(int x, int y) {
|
public void clickCell(int x, int y) {
|
||||||
int currentCellValue = getCell(x, y);
|
if (clickActionFlag) {
|
||||||
int newCellValue;
|
int currentCellValue = getCell(x, y);
|
||||||
if (currentCellValue == 0) {
|
int newCellValue;
|
||||||
System.out.println("Cell :" + x + "," + y + " is now alive");
|
if (currentCellValue == 0) {
|
||||||
newCellValue = 1; // If the cell is dead, make it alive
|
System.out.println("Cell :" + x + "," + y + " is now alive");
|
||||||
|
newCellValue = 1; // If the cell is dead, make it alive
|
||||||
|
} else {
|
||||||
|
System.out.println("Cell :" + x + "," + y + " is now dead");
|
||||||
|
newCellValue = 0; // If the cell is alive, make it dead
|
||||||
|
}
|
||||||
|
|
||||||
|
setCell(x, y, newCellValue);
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Cell :" + x + "," + y + " is now dead");
|
return;
|
||||||
newCellValue = 0; // If the cell is alive, make it dead
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setCell(x, y, newCellValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -277,11 +281,13 @@ public class Simulator extends Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLoopDelay(int delay) {
|
public void setLoopDelay(int delay) {
|
||||||
//TODO : complete method
|
//TODO-COMPLETE : complete method
|
||||||
|
loopDelay = delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleClickAction() {
|
public void toggleClickAction() {
|
||||||
//TODO : complete method
|
//TODO-COMPLETE : complete method
|
||||||
|
clickActionFlag = !clickActionFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue