Part 2: the Mandatory methods

This commit is contained in:
matheo.estor 2024-05-14 16:25:01 +02:00
parent d1a06c5d46
commit e6d5262178
1 changed files with 16 additions and 23 deletions

View File

@ -50,13 +50,11 @@ public class Simulator extends Thread {
}
public int getWidth() {
//TODO : replace with proper return
return 0;
return COL_NUM;
}
public int getHeight() {
//TODO : replace with proper return
return 0;
return LINE_NUM;
}
//Should probably stay as is
@ -136,14 +134,20 @@ public class Simulator extends Thread {
* method called when clicking pause button
*/
public void togglePause() {
// TODO : actually toggle the corresponding flag
pauseFlag = !pauseFlag;
}
/**
* method called when clicking on a cell in the interface
*/
public void clickCell(int x, int y) {
//TODO : complete method
if (clickActionFlag) {
agents.add(new Sheep(x, y));
} else {
int currentValue = getCell(x, y);
int newValue = (currentValue == 0) ? 1 : 0;
setCell(x, y, newValue);}
}
/**
@ -153,8 +157,7 @@ public class Simulator extends Thread {
* @return value of cell
*/
public int getCell(int x, int y) {
//TODO : complete method with proper return
return 0;
}
/**
*
@ -188,7 +191,7 @@ public class Simulator extends Thread {
* @param val to set in cell
*/
public void setCell(int x, int y, int val) {
//TODO : complete method
}
/**
@ -197,7 +200,6 @@ public class Simulator extends Thread {
* the simulated world in its present state
*/
public ArrayList<String> getSaveState() {
//TODO : complete method with proper return
return null;
}
/**
@ -241,14 +243,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
*/
}
public boolean isLoopingBorder() {
@ -259,11 +254,11 @@ public class Simulator extends Thread {
loopingBorder = !loopingBorder;
}
public void setLoopDelay(int delay) {
//TODO : complete method
loopDelay = delay;
}
public void toggleClickAction() {
//TODO : complete method
clickActionFlag = !clickActionFlag;
}
/**
@ -321,9 +316,7 @@ public class Simulator extends Thread {
* @return String representation of click action
*/
public String clickActionName() {
// TODO : initially return "sheep" or "cell"
// depending on clickActionFlag
return "";
return clickActionFlag ? "Sheep" : "Cell";
}
}