Refactoring (?): isAlive() tatsächliche Überprüfung eingefügt, dazu setAlive() nötig etc.
This commit is contained in:
parent
41e60e145b
commit
fc7a99931f
Binary file not shown.
Binary file not shown.
@ -1,5 +1,6 @@
|
|||||||
public class Life implements ILife {
|
public class Life implements ILife {
|
||||||
|
|
||||||
|
private boolean[][] grid = new boolean[5][5]; // vorläufig 5x5 Raster
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Life l = new Life(new String[] { " ",
|
Life l = new Life(new String[] { " ",
|
||||||
@ -32,7 +33,7 @@ public class Life implements ILife {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAlive(int x, int y) {
|
public void setAlive(int x, int y) {
|
||||||
// TODO Auto-generated method stub
|
grid[x][y] = true; // damit Test grün wird, muss Zelle im grid true (alive) werden
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -43,12 +44,18 @@ public class Life implements ILife {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAlive(int x, int y) {
|
public boolean isAlive(int x, int y) {
|
||||||
return true;
|
// REFACTORING: return nicht mehr einfach auf 'true' setzen, sondern tatsächlich eine Überprüfung ausführen
|
||||||
|
|
||||||
|
// Zustand der Zelle an Position (x, y)
|
||||||
|
return grid[x][y];
|
||||||
|
|
||||||
|
// -> grid muss erstellt werden, siehe Zeile 3
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ILife nextGeneration() {
|
public ILife nextGeneration() {
|
||||||
Life next = new Life();
|
Life next = new Life();
|
||||||
|
next.setAlive(1,1); // muss jetzt ausgelöst werden, damit Zelle alive wird
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user