@@ -54,11 +54,11 @@ public:
5454 );
5555
5656 void setCellStatus (unsigned int row, unsigned int column, LifeState cellStatus);
57- LifeState getCellStatus (unsigned int row, unsigned int column) const ;
57+ LifeState getCellStatus (int row, int column) const ;
5858 void createRandomState ();
5959
60- bool isAlive (unsigned int row, unsigned int column) const ;
61- int countAliveNeighbors (unsigned int row, unsigned int column) const ;
60+ bool isAlive (int row, int column) const ;
61+ int countAliveNeighbors (int row, int column) const ;
6262
6363 void drawToScreen ();
6464};
@@ -77,7 +77,7 @@ CellUniverse::CellUniverse(
7777}
7878
7979void CellUniverse::setCellStatus (unsigned int row, unsigned int column, LifeState cellStatus) {
80- if (row < 0 || row >= _leds.rows () || column < 0 || column >= _leds.columns ()) {
80+ if (row >= _leds.rows () || column >= _leds.columns ()) {
8181 return ;
8282 }
8383
@@ -86,13 +86,13 @@ void CellUniverse::setCellStatus(unsigned int row, unsigned int column, LifeStat
8686 _cells[idx] = cellStatus;
8787}
8888
89- CellUniverse::LifeState CellUniverse::getCellStatus (unsigned int row, unsigned int column) const {
89+ CellUniverse::LifeState CellUniverse::getCellStatus (int row, int column) const {
9090 // this causes the matrix to be a toroidal array
9191 unsigned int r = row < 0 ? row + _leds.rows () : ( row >= _leds.rows () ? row - _leds.rows () : row );
9292 unsigned int c = column < 0 ? column + _leds.columns () : ( column >= _leds.columns () ? column - _leds.columns () : column );
9393
9494 // double check just to be sure
95- if (r < 0 || r >= _leds.rows () || c < 0 || c >= _leds.columns ()) {
95+ if (r >= _leds.rows () || c >= _leds.columns ()) {
9696 return CellUniverse::DEAD;
9797 }
9898
@@ -101,15 +101,15 @@ CellUniverse::LifeState CellUniverse::getCellStatus(unsigned int row, unsigned i
101101 return _cells[idx];
102102}
103103
104- bool CellUniverse::isAlive (unsigned int row, unsigned int column) const {
104+ bool CellUniverse::isAlive (int row, int column) const {
105105 return (this ->getCellStatus (row, column) == CellUniverse::ALIVE || this ->getCellStatus (row, column) == CellUniverse::BORN);
106106}
107107
108- int CellUniverse::countAliveNeighbors (unsigned int row, unsigned int column) const {
108+ int CellUniverse::countAliveNeighbors (int row, int column) const {
109109 int aliveCount = 0 ;
110110
111- for (unsigned int x = column - 1 ; x <= column+1 ; x++) {
112- for (unsigned int y = row - 1 ; y <= row + 1 ; y++ ) {
111+ for (int x = column - 1 ; x <= column+1 ; x++) {
112+ for (int y = row - 1 ; y <= row + 1 ; y++ ) {
113113 if (this ->isAlive (y, x) && !(x == column && y == row)) {
114114 aliveCount++;
115115 }
0 commit comments