Laboratory 2 Solutions
Solution to life1.h code:
/******************************************************************* * Name: Brenda Student * Date: 1/28/14 * Course: CSCI 132 * Assignment: Lab2 * Instructor: Royden * Program file: life1.h * Purpose: Specification of Life class with wrap-around grid. ********************************************************************/ // 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 ][maxcol]; // allows for two extra rows and columns int neighbor_count(int row, int col); };
Home | | Syllabus | | Assignments | | Lecture Notes