Question: NEED C++ HELP. PLEASE FOLLOW DIRECTIONS CAREFULLY : Use a 1 dimensional array object to create a 2 dimensional table object. Then modify to create

NEED C++ HELP. PLEASE FOLLOW DIRECTIONS CAREFULLY:

Use a 1 dimensional array object to create a 2 dimensional table object. Then modify to create a triangular table.

Objective -> create an array of dynamic objects of RowAray inside Table i.e. an Aggregate. See Specs RowAray.h, Table.h Then create a triangular table, i.e. Triangle.

Fill each cell with random 2 digit integers. The example Table has 8 columns of RowAray objects each filled with 6 rows of random 2 digit numbers.

Then create a triangular table using the concept of the original table.

Complete the class implementations RowAray.cpp, Table,cpp, and Triangle.cpp use the driver program, obtain similar results.

RowArray.h:

8 #ifndef ROWARAY_H 9 #define ROWARAY_H 10 11 12 13 class RowAray{

Table.h:

private: int size; 14 int rowData; 15 public: 16 17 18 19

Triangle.h:

RowAray(int); ~RowAray(); int getSize(){return size; } int getData(int i){return rowData[i];} 20 };

main.cpp:

21 22 #endif /* ROWARAY_H */image text in transcribedimage text in transcribed

#include
#include
#include
using namespace std;
//User Libraries
#include "Table.h"
#include "Triangle.h"
//Global Constants
//Function Prototype
void prntRow(RowAray *,int);
void prntTab(Table *);
void prntTri(Triangle *);
//Execution Begins Here!
int main(int argc, char** argv) {
//Initialize the random seed
srand(static_cast(time(0)));
//Declare Variables
int rows=6,cols=8,perLine=cols/2;
//Test out the RowAray
RowAray row(cols);
//Print the RowAray
cout
prntRow(&row,perLine);
//Test out the Table
Table tab(rows,cols);
//Print the Table
cout
prntTab(&tab);
//Test out the Triangular Table
Triangle tri(rows);
//Print the Triangular Table
cout
prntTri(&tri);
//Exit Stage Right
return 0;
}
void prntRow(RowAray *a,int perLine){
cout
for(int i=0;igetSize();i++){
cout
if(i%perLine==(perLine-1))cout
}
cout
}
void prntTab(Table *a){
cout
for(int row=0;rowgetSzRow();row++){
for(int col=0;colgetSzCol();col++){
cout
}
cout
}
cout
}
void prntTri(Triangle *a){
cout
for(int row=0;rowgetSzRow();row++){
for(int col=0;col
cout
}
cout
}
cout

}

Example Table:

image text in transcribed

8 #ifndef ROWARAY_H 9 #define ROWARAY_H 10 11 12 13 class RowAray{ private: int size; 14 int rowData; 15 public: 16 17 18 19 RowAray(int); ~RowAray(); int getSize(){return size; } int getData(int i){return rowData[i];} 20 }; 21 22 #endif /* ROWARAY_H */

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 Programming Questions!