add logs
This commit is contained in:
parent
3c05da825f
commit
4f2cb09640
|
|
@ -28,6 +28,7 @@ public class Simulator extends Thread {
|
||||||
//TODO : add missing attribute(s)
|
//TODO : add missing attribute(s)
|
||||||
private int width;
|
private int width;
|
||||||
private int height;
|
private int height;
|
||||||
|
private boolean enableLogs;
|
||||||
|
|
||||||
public Simulator(MyInterface mjfParam) {
|
public Simulator(MyInterface mjfParam) {
|
||||||
mjf = mjfParam;
|
mjf = mjfParam;
|
||||||
|
|
@ -44,6 +45,7 @@ public class Simulator extends Thread {
|
||||||
//might want to changes those values later
|
//might want to changes those values later
|
||||||
this.width=100;
|
this.width=100;
|
||||||
this.height=100;
|
this.height=100;
|
||||||
|
enableLogs = true;
|
||||||
|
|
||||||
|
|
||||||
//Default rule : Survive always, birth never
|
//Default rule : Survive always, birth never
|
||||||
|
|
@ -142,6 +144,13 @@ public class Simulator extends Thread {
|
||||||
public void togglePause() {
|
public void togglePause() {
|
||||||
// TODO-COMPLETE : actually toggle the corresponding flag
|
// TODO-COMPLETE : actually toggle the corresponding flag
|
||||||
pauseFlag = !pauseFlag;
|
pauseFlag = !pauseFlag;
|
||||||
|
if (enableLogs) {
|
||||||
|
if (pauseFlag) {
|
||||||
|
System.out.println("togglePause called, Simulation paused");
|
||||||
|
} else {
|
||||||
|
System.out.println("togglePause called, Simulation unpaused");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -152,10 +161,14 @@ public class Simulator extends Thread {
|
||||||
int currentCellValue = getCell(x, y);
|
int currentCellValue = getCell(x, y);
|
||||||
int newCellValue;
|
int newCellValue;
|
||||||
if (currentCellValue == 0) {
|
if (currentCellValue == 0) {
|
||||||
System.out.println("Cell :" + x + "," + y + " is now alive");
|
if (enableLogs) {
|
||||||
|
System.out.println("clickCell Called, cell :" + x + "," + y + " is now alive");
|
||||||
|
}
|
||||||
newCellValue = 1; // If the cell is dead, make it alive
|
newCellValue = 1; // If the cell is dead, make it alive
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Cell :" + x + "," + y + " is now dead");
|
if (enableLogs) {
|
||||||
|
System.out.println("clickCell Called, cell :" + x + "," + y + " is now dead");
|
||||||
|
}
|
||||||
newCellValue = 0; // If the cell is alive, make it dead
|
newCellValue = 0; // If the cell is alive, make it dead
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -283,11 +296,21 @@ public class Simulator extends Thread {
|
||||||
public void setLoopDelay(int delay) {
|
public void setLoopDelay(int delay) {
|
||||||
//TODO-COMPLETE : complete method
|
//TODO-COMPLETE : complete method
|
||||||
loopDelay = delay;
|
loopDelay = delay;
|
||||||
|
if (enableLogs) {
|
||||||
|
System.out.println("Loop delay set to " + delay);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleClickAction() {
|
public void toggleClickAction() {
|
||||||
//TODO-COMPLETE : complete method
|
//TODO-COMPLETE : complete method
|
||||||
clickActionFlag = !clickActionFlag;
|
clickActionFlag = !clickActionFlag;
|
||||||
|
if (enableLogs) {
|
||||||
|
if (clickActionFlag) {
|
||||||
|
System.out.println("toggleClickAction called, set clickActionFlag to true");
|
||||||
|
} else {
|
||||||
|
System.out.println("toggleClickAction called, set clickActionFlag to false");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue