Skip to content
Snippets Groups Projects
Commit 061efca8 authored by Goik Martin's avatar Goik Martin
Browse files

living --> ALIVE, dead --> DEAD

parent 3dd63255
Branches
No related tags found
No related merge requests found
......@@ -34,7 +34,7 @@ public class Cell extends Actor {
* Create the cell body's image and initialize state.
*
* @param cellSize The cell's size in pixel units,
* @param intialState Indicating {@link CellState#living} or {@link CellState#dead}
* @param intialState Indicating {@link CellState#ALIVE} or {@link CellState#DEAD}
*/
public Cell(int cellSize, CellState intialState) {
super();
......@@ -72,7 +72,7 @@ public class Cell extends Actor {
/**
* Get the state of the cell.
* @return Either {@link CellState#living} or {@link CellState#dead}.
* @return Either {@link CellState#ALIVE} or {@link CellState#DEAD}.
*/
public CellState getState() {
return state;
......@@ -94,7 +94,7 @@ public class Cell extends Actor {
public int getLivingNeighborCount() {
int sum = 0;
for (final Cell neighbor: neighbors) {
if (CellState.living == neighbor.previousState) {
if (CellState.ALIVE == neighbor.previousState) {
sum ++;
}
}
......@@ -107,18 +107,18 @@ public class Cell extends Actor {
public void applyRule() {
final int livingNeighborsCount = getLivingNeighborCount();
if (CellState.living == previousState) { // Living Cell
if (CellState.ALIVE == previousState) { // Living Cell
if (livingNeighborsCount < 2 || // Dying on account of under-population
3 < livingNeighborsCount) { // Dying on account of overcrowding
state = CellState.dead;
state = CellState.DEAD;
} else { // two or three living neighbors
state = CellState.living;
state = CellState.ALIVE;
}
} else { // cell is dead
if (3 == livingNeighborsCount) { // Born by reproduction
state = CellState.living;
state = CellState.ALIVE;
} else { // remain dead
state = CellState.dead;
state = CellState.DEAD;
}
}
}
......
......@@ -6,13 +6,13 @@ import java.awt.Color;
*/
public enum CellState {
/**
* Cell lives.
* Cell is alive.
*/
living(Color.black, "Cell is in 'living' state") ,
ALIVE(Color.black, "Cell is in 'alive' state") ,
/**
* Cell is dead.
*/
dead(Color.white, "Cell is in 'dead' state");
DEAD(Color.white, "Cell is in 'dead' state");
/**
* The cell's color when rendered.
......@@ -23,8 +23,8 @@ public enum CellState {
private CellState inverseState;
static { // "Class" constructor. You may want to read the
living.inverseState = dead; // "Using Initialization Blocks" subsection within the
dead.inverseState = living; // "Initializing Data Members" section of Ivor Horton's
ALIVE.inverseState = DEAD; // "Using Initialization Blocks" subsection within the
DEAD.inverseState = ALIVE; // "Initializing Data Members" section of Ivor Horton's
} // Java introduction.
CellState(final Color color, final String description) {
......@@ -37,8 +37,8 @@ public enum CellState {
}
/**
* @return {@link #living} if current value is {@link #dead},
* {@link #dead} if current value is {@link #living}
* @return {@link #ALIVE} if current value is {@link #DEAD},
* {@link #DEAD} if current value is {@link #ALIVE}
*/
public CellState getInverseState() {
return inverseState;
......
......@@ -162,13 +162,13 @@ public class LifeWorld extends World {
return neighbors;
}
/** Randomly return the two states {@link CellState#living} and {@link CellState#dead}. The
/** Randomly return the two states {@link CellState#ALIVE} and {@link CellState#DEAD}. The
* corresponding probabilities depend on the value of {@link #setInitialLivingPercentage(int)}.
*
* @return Either {@link CellState#living} or {@link CellState#dead}.
* @return Either {@link CellState#ALIVE} or {@link CellState#DEAD}.
*/
public static CellState getRandomLifeOrDeadState() {
return Greenfoot.getRandomNumber(100) < initialLivingPercentage ?
CellState.living : CellState.dead;
CellState.ALIVE : CellState.DEAD;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment