Question: This is the program to correct: There are no files for the boolMatrix class (boolMatrix.h and boolMatrix.cpp). Could you please fix this? #include #include using

This is the program to correct: There are no files for the boolMatrix class (boolMatrix.h and boolMatrix.cpp). Could you please fix this?

#include

#include

using namespace std;

class boolMatrix

{

bool a[20][20];

public:

static const int NUM_ROWS = 20;

static const int NUM_COLS = 20;

boolMatrix()

{int i,j;

for(i=0;i<20;i++)

for(j=0;j<20;j++)

a[i][j]=false;

}

void get(int,int);

void set(int,int,bool);

int rowCount(int);

int colCount(int);

int totalCount();

int neighborCount(int,int);

};

void boolMatrix::get(int i, int j)

{ assert(i >= 0 && i < NUM_ROWS);

assert(j >= 0 && j< NUM_COLS);

cout<

}

void boolMatrix::set(int i, int j, bool val)

{ assert(i >= 0 && i < NUM_ROWS);

assert(j >= 0 && j < NUM_COLS);

a[i][j]=val;

}

int boolMatrix::rowCount(int i)

{int count=0;

assert(i >= 0 && i < NUM_ROWS);

for(int l=0;l

{if(a[i][l]==true)

count++;

}

return count;

}

int boolMatrix::colCount(int j)

{int count=0;

assert(j >= 0 && j < NUM_COLS);

for(int l=0;l

{if(a[l][j]==true)

count++;

}

return count;

}

int boolMatrix::totalCount()

{int count=0;

for(int i=0;i

for(int j=0;j

if(a[i][j]==true)

count++;

return count;

}

int boolMatrix::neighborCount(int k,int l)

{

int count=0;

for(int i=k-1;i

{

if(i<0)

++i;

if(i>=NUM_ROWS)

break;

for(int j=l-1;j

{if(j<0)

++j;

if(i>=NUM_COLS)

break;

if(!(i==k && j==l))

{

if (a[i][j] == true)

count++;

}

}

}

return count;

}

int main()

{

boolMatrix h1;

int i,j,k,c;

bool val;

cout<<"enter your choice";

cout<<"1.get ";

cout<<"2.set ";

cout<<"3.rowcount ";

cout<<"4.colcount ";

cout<<"5.totalCount ";

cout<<"6.neighborCount ";

cout<<"enter ur choice";

cin>>c;

switch(c)

{

case 1:{

cout<<"enter the row and col number:"<

cin>>i;

cin>>j;

h1.get(i,j);

break;

}

case 2:{

cout<<"enter the row and col number:"<

cin>>i>>j;

cout<<"enter the value to be set: true/false";

cin>>val;

h1.set(i,j,val);

break;

}

case 3:{

cout<<"enter the row number:"<

cin>>i;

k=h1.rowCount(i);

cout<<"no. of cells in row no."<

break;

}

case 4:{

cout<<"enter the col number:"<

cin>>j;

k=h1.colCount(j);

cout<<"no. of cells in col no."<

break;

}

case 5:

{

k=h1.totalCount();

cout<<"no. of cells in array has"<

break;

}

case 6:

{

cout<<"enter the row and col number:"<

cin>>i>>j;

k=h1.neighborCount(i,j);

cout<<"no. of neighbours with true values are"<

break;

}

default:cout<<"enter correct choice:";

}

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!