/**
* @file Life.h
* @class Life
* @author csc
326 class
* @date
September 2, 2010
*/
/**Definition of
a Life Class */
class Life
{
public:
//Life (int rowvalue, int
columnvalue);
Life();
/** Sets row value
* @pre None
* @post row is modifed to reflect current
row position
* @param rowvalue contains current row
position
*/
void setrow (int rowvalue){ row = rowvalue;};
int getrow () const {return row;};
/** Sets column value
* @pre None
* @post column is modifed to reflect
current column position
* @param columnvalue contains current
column position
*/
void setcolumn (int columnvalue) {column = columnvalue;};
int getcolumn () const {return
column;};
int checker (int rowvalue, int
columnvalue);
void display();
void deadOrAlive();
void clone();
private:
int row;
int column;
int grid_current[22][62];
int grid_nextgen[22][62];
}; //end
Life
Life::Life()
{
int i, j;
for (i = 0; i < 22;
i++)
for (j = 0; j <
62; j++)
grid_current[i][j] = 0;
grid_current[10][10] = 1;
grid_current[10][11] = 1;
grid_current[10][12] = 1;
}
/** Checker
counts the number of positions that contain values surrounding
* the given row, columnn position
* @pre given a
row and column position and the position is in the center of a
* 3 X 3 grid
* @post count is
modified to reflect the number of cells surrounding the
* center of a 3 X 3 grd that contain values
* @param
rowvalue contains current row position in larger grid
* @param
columnvalue contains current column position in larger grid
* @return
returns value of number of surrounding cells of
* current location containing a value (count)
*/
int
Life::checker (int rowvalue, int columnvalue)
{
int count = 0;
//check row above current position
for (int
i = columnvalue-1;i <= columnvalue + 1; i++)
if
(grid_current[rowvalue-1][i]) count++;
//check row of current position
if
(grid_current[rowvalue][columnvalue-1]) count++;
if
(grid_current[rowvalue][columnvalue+1]) count++;
//check row below current position
for (int
i = columnvalue-1;i <= columnvalue + 1; i++)
if
(grid_current[rowvalue+1][i]) count++;
return count;
}
void
Life::display(){ cout << "display
stuff" << endl;}
void
Life::deadOrAlive(){ cout << "deadOrAlive
stuff" << endl;}
void Life::clone(){ cout << "clone stuff" << endl;}