Question: Develop a program that builds a three - dimensional array ( dynamically ) to point to Cell Objects. Make sure the Cell object's keep track
Develop a program that builds a threedimensional array dynamically to
point to Cell Objects. Make sure the Cell object's keep track of their xyz
location and contains a dynamic array elements to function pointers. Use
a tick function to animate the array, printing the cells location and call a
function from the array. The function can be static functions of the class.
Make sure you exercise the creating and deleting of the array. You must use
separate files for the Cell header and implementation files and where main is
located. Make sure to include appropriate pragmas for conditional
compilation of code.
Filed to be Created
Cell
Cell.h
main
Sample code:
Cell.H
#pragma once
class Cell
public:
Cellint x int y int z;
~Cell;
void tick;
static void functionint x int y int z;
private:
int x y z;
int dynamicArray;
static void internalFunctionint x int y int z;
;
Cell.cpp
#include "Cell.h
#include
Cell::Cellint x int y int z : xx yy zz
dynamicArray new int;
Cell::~Cell
delete dynamicArray;
void Cell::tick
std::cout "Cell at x y z is
ticking." std::endl;
Cell::functionx y z;
void Cell::functionint x int y int z
std::cout "Function called from Cell at x y
z std::endl;
void Cell::internalFunctionint x int y int z
std::cout "Internal function called from Cell at x
y z std::endl;
Main.cpp
int buildArrayint x int y int z
int tmp;
tmp new intz;
for int aZ ; aZ z; aZ
tmpaZ new inty;
for int aY ; aY y; aY
tmpaZaY new int x;
return tmp;
void populateArrayint A int x int y int z
int i j k;
for i; i z; i
for j; j y; j
for k; k x; k
Aijk rand;
void printArrayint A int x int y int z
int i j k;
cout "Printing array of size z z y y x x endl
endl;
for i ; i z; i
cout z i endl;
for j ; j y; j
for k ; k x; k
cout Aijk;
cout endl;
cout endl;
int deleteArrayintA int x int y int z
for int aZ ; aZ z; aZ
for int aY ; aY y; aY
delete AaZaY;
delete AaZ;
delete A;
return NULL;
bool AgainArrayint x int y int z
char ch;
cout Try again to build new array y or n :;
cin ch;
ch toupperch;
if ch Y return false;
cout "Enter value for z:;
cin z;
cout "Enter value for y:;
cin y;
cout "Enter value for x:;
cin x;
return true;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
