Urgently C++ help needed. Need a code, I have very basic knowledge of c++ if any help would be much appreciated! Thanks!

Urgently C++ help needed. Trying to to develop a C++ program for the Game of Life restricted to a finite board (n ✕ n). Need a general idea of creating constructor and methods by using below requirements. I have very basic knowledge of c++ if any help would be much appreciated! Thanks!


1.1. The Implementation Requirements.!

• The space of GLT should be implemented as a (n ✕ n) twodimensional
array of integers, int **board, containing
only zeros and ones.!
• Transition rules (1-4) of the restricted game are the same
as of the classical game. !
• Neighbours of the cell board[i][j] are the following 8
elements:!
board[(i-1+n)%n][(j-1+n)%n],board[(i-1+n)%n][j], !
board[(i-1+n)%n][(j+1)%n],board[i%n][(j+1)%n],!
board[(i+1)%n][(j+1)%n],board[(i+1)%n][j],!
board[(i+1)%n][(j-1+n)%n], board[i][(j-1+n)%n].

Class Game_of_life.

You are required to develop a class Game_of_life using the
header file, Game_of_life.h, given below. I.e. you should
write the implementation file Game_of_life.c.!

Game_of_life.h

#ifndef game_of_life_h
#define game_of_life_h !
#include <iostream> !
using namespace std; !
class Game_of_life{
public:
Game_of_life();
Game_of_life(int);
~Game_of_life();
void set_configuration(int**);
void next_configuration();
friend ostream &operator<<(ostream &stream, Game_of_life &m);
private:
int **board;
const int size;
int neighbour_sum(int,int);
}; !
#endif

Here are the requirements for the implementation

• Instance variables!

• const int size - the size of the board where the game of life
is played.

• int **board - two-dimensional array of integers that
represents the board where the game of life is played. The
array must be created dynamically in the constructors. Also,
it must be properly destroyed in the destructor. !

• Constructors & Methods(functions) of the class !

-Game_of_life() - the default constructor; sets size to 20 and
dynamically creates 20✕20 board.

-Game_of_life(int size) - a constructor with one integer
parameter that is used to initialise size; dynamically creates
a (size✕size) board.

-~Game_of_life() - the destructor; destroys board.

-void set_board(int** b) - public method(function); sets the
board to b; for simplicity, assume that b has the same size as
your board.

-void next_configuration() - public method(function);
calculates and sets the next configuration of the board
according to the game’s rules.

-friend ostream &operator<<(ostream &stream, Game_of_life &m) -
prints the current board on the screen; instead of '1' it
prints ‘*’, instead of ‘0' it prints ‘ ‘(white space).

-int neighbour_sum(int i,int j) - private method; should be
used in the next_configuration(); returns sum of the
neighbouring cells of the cell with the coordinates (i,j).

Please help me as i have to finish it off as urgent as possible.. Thanks once again!!!!
Have you done anything yet that you could show everybody so you can get help
Topic archived. No new replies allowed.