Problem in Java “change in the status of a cell.”
Hello,
I have a small question about OOP. Let me explain:
I have a Grid object:
Code :
1.import java.util.*;
2.import java.io.*;
3.import java.lang.Math;
4.public class Grid {
5.private static Cell[][] grid;
6.private int sizeOfGrid;
7.public Grid(int size) { // Déclaration d'un tableau de cellules
8.sizeOfGrid = size;
9.grid = new Cell[size][size];
10.}
The grid object is an array of subject Cell:
Code :
1.public class Cell {
2.private CellStatus status;
3.private int aliveNeighbour;
4.public Cell() {
5.status.makeCellDead();
6.aliveNeighbour = 0;
7.}
and finally, the class Cell contains an object CellStatus:
Code :
1.public class CellStatus {
2.private boolean alive;
3.public CellStatus (boolean isAlive) {
4.alive = isAlive;
5.}
The Boolean object alive CellStatus can see if a cell is alive or dead. In the program, I have to change the status of a cell.
For example: grid [x] [y]. MakeCellDead ();
I wonder how I do it. If the variables must be static, etc …
thank you