Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Use a 1 dimensional array object to create a 2 dimensional table object. Then modify to create a triangular table. Objective -> create an

C++

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

code

main.cpp

/* * File: main.cpp * Author: * Created on January 22nd, 2019, 8:36 PM * Purpose: Dynamic Object Arrays */

//User Libraries #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<<"The Row Array size = "<

prntRow(&row,perLine); //Test out the Table Table tab(rows,cols); //Print the Table cout<<"The table size is [row,col] = ["<

//Exit Stage Right return 0; }

void prntRow(RowAray *a,int perLine){ cout<getSize();i++){ cout<getData(i)<<" "; if(i%perLine==(perLine-1))cout<

void prntTab(Table *a){ cout<getSzRow();row++){ for(int col=0;colgetSzCol();col++){ cout<getData(row,col)<<" "; } cout<

void prntTri(Triangle *a){ cout<getSzRow();row++){ for(int col=0;col<=row;col++){ cout<getData(row,col)<<" "; } cout<

Triangle.h

/* * File: Triangle.h * Author: * Created on January 22nd, 2019, 8:36 PM * Purpose: Specification of a Triangular array from a Row Array */

#ifndef TRIANGLE_H #define TRIANGLE_H

#include "RowAray.h"

class Triangle{ private: int szRow; RowAray **records; public: Triangle(int); ~Triangle(); int getSzRow(){return szRow;} int getData(int,int); };

#endif /* TRIANGLE_H */

Table.h

/* * File: Table.h * Author: * Created on January 22nd, 2019, 8:36 PM * Specification for the Table */

#ifndef TABLE_H #define TABLE_H

#include "RowAray.h"

class Table{ private: int szRow; int szCol; RowAray **records; public: Table(int,int); ~Table(); int getSzRow(){return szRow;} int getSzCol(){return szCol;} int getData(int,int); };

#endif /* TABLE_H */

RowAray.h

/* * File: RowAray.h * Author: Dr. Mark E. Lehr * Created on January 22nd, 2019, 8:36 PM * Specification for the RowAray */

#ifndef ROWARAY_H #define ROWARAY_H

class RowAray{ private: int size; int *rowData; public: RowAray(int); ~RowAray(); int getSize(){return size;} int getData(int i){return rowData[i];} };

#endif /* ROWARAY_H */

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming Languages 12th International Symposium Dbpl 2009 Lyon France August 2009 Proceedings Lncs 5708

Authors: Philippa Gardner ,Floris Geerts

2009th Edition

3642037925, 978-3642037924

More Books

Students also viewed these Databases questions

Question

2. In what way can we say that method affects the result we get?

Answered: 1 week ago