A simple Game of Life implementation in Java
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Grid.java 655 B

1234567891011121314151617181920212223242526272829
  1. public class Grid {
  2. private Patch[][] _grid;
  3. public Grid() {
  4. _grid = new Patch[1][1];
  5. _grid[0][0] = new Patch(this, 0, 0);
  6. }
  7. public Grid(int x, int y) {
  8. _grid = new Patch[x][y];
  9. for(int i = 0; i < x; i++) {
  10. for(int j = 0; j < y; j++) {
  11. _grid[i][j] = new Patch(this, i, j);
  12. }
  13. }
  14. }
  15. public String toString() }
  16. String ans = "";
  17. for(int i = 0; i < _grid.length; i++) {
  18. for(int j = 0; j < _grid[i].length; j++) {
  19. ans += _grid[i][j];
  20. }
  21. ans += "\n";
  22. }
  23. return ans;
  24. }
  25. }