Refactoring: vermeide zwei fast identische Codeblöcke (if-Abfragen)
This commit is contained in:
parent
89bf74f0c3
commit
2763a28619
Binary file not shown.
@ -54,9 +54,9 @@ public class Life implements ILife {
|
||||
for (int x = 0; x < grid[y].length; x++) {
|
||||
if (countAliveNeighbours(x, y) == 3) {
|
||||
next.setAlive(x, y);
|
||||
} else if (countAliveNeighbours(x, y) < 2) {
|
||||
next.setDead(x, y);
|
||||
} else if (countAliveNeighbours(x, y) > 3) {
|
||||
}
|
||||
// Refactoring: vermeide zwei fast identische Codeblöcke, also Dopplung, mittels zusammenziehen der if's
|
||||
else if (countAliveNeighbours(x, y) < 2 || countAliveNeighbours(x, y) > 3) {
|
||||
next.setDead(x, y);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user