Laboratory 2 Solutions
Solution to life.h code:
/*******************************************************************
* Name: Brenda Student
* Date: 1/28/2014
* Course: CSCI 132
* Assignment: Lab2
* Instructor: Royden
* Program: life.h
* Purpose: Specification file for the Life class.
********************************************************************/
// Section 1.4 (contents of life.h file)
#include <iostream>
using namespace std;
const int maxrow = 20, maxcol = 60; // grid dimensions
class Life {
public:
void initialize();
void print();
void update();
private:
int grid[maxrow+2][maxcol+2 ]; // allows for two extra rows and columns
int neighbor_count(int row, int col);
};
Home | | Syllabus | | Assignments | | Lecture Notes