print function in classes

Can someone please help me to implement a function that will make my output look like this:

Box# Box Type Volume(cu/units)
1 Square 9
2 Rectangular 212
3 ? ?
4 ? ?
5 ? ?


My problem is with storing each box's type and volume, as my print1Box function works fine so all of my calculations should be correct, yet printing in this format is tricky because it forces me to instantiate a new object using the respective box type and volume so i can then call printData on the new object. I am not too sure how to do this and have been stuck for a while. Please let me know if you can help.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
#include <stdio.h>
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
#include <cstdlib>

using namespace std;

//-----------------------------------------------------------------------------------------------------------------------------
class Box
{
	  public:
    	Box();
		Box(int,string);
		int boxid;
        int getDepth();
		int getWidth();
		int getHeight(int heightstore);
		int getVolume();
		int getMaxX();
		int getMaxY();
		int getMinY();
		int getMinX();
        string getType();
		void print1Box(int a);
		void setData(int heightstore);
		void printData(int a, string sarray[5]);
		void setMoreData();
		void printVolume();
		int xcoords[4];
		int ycoords[4];
		string sarray[5];
	
	private:
        int m_volume;
        int m_width;
        int m_depth;
        int m_height;
        string m_type;
		int m_sumvolume;
		int local_maxx;
		int local_maxy;
		int local_minx;
		int local_miny;
};
//-----------------------------------------------------------------------------------------------------------------------------
Box::Box()
{
	m_volume = 0;
	xcoords[4] = 0;
	ycoords[4] = 0;
    local_maxx = 0;
	local_maxy = 0;
	local_miny = 0;
	local_minx = 0;
	m_width = 0;
    m_depth = 0;
    m_height =0;
    string m_type = "";
	m_sumvolume = 0;
} 
Box::Box(int a, string b)
{
	boxid = a;
	sarray[0] = b;
}

void Box::setData(int heightstore)
{
    for (int j=0; j<4; j++)
    {
        cout << "\n\n\tEnter X, Y: " << endl;
        cin >> xcoords[j] >> ycoords[j];
    }

	cout << "\n\n\tEnter Height: " << endl;
	cin >> heightstore;

    m_height = heightstore;
    m_width = xcoords[2] - xcoords[0]; // Width
    m_depth = ycoords[1] - ycoords[0]; // Depth
    m_volume = getVolume();
}

void Box::print1Box(int a)
{
	boxid = a;
	cout << left << setw(25) << "Box#";
	cout << left << setw(25) << "Box Type";
	cout << right << setw(25) << "Volume(cu/units)";
	cout << "\n" << endl;
	cout << left << setw(25) << boxid << left << setw(25) << m_type << right << setw(25) << m_volume << endl;
}

void Box::printData(int a, string sarray[5]) 
{
	boxid = a;
	 m_type = sarray[5];
	cout << left << setw(25) << "Box#";
	cout << left << setw(25) << "Box Type";
	cout << right << setw(25) << "Volume(cu/units)";
    {
        for (int i=0;i<5;i++) 
        {
			cout << left << setw(25) << boxid << left << setw(25) << sarray[i] << right << setw(25) << m_volume << endl;
        }       
		//will return m_type for box 1 but not m_type for each object. although each
		//instantiated object has a boxid and a m_type, m_type has not been stored for each specific object, 
		//while boxid is passed as an argument of int i to set the box numbers. for storing m_type to prepare it for
		//print, i think we should 
    }
}
void Box::printVolume()
{
	cout << "The total volume of the shipment is: 649(cu/units)" <<endl;
}

string Box::getType() 
{
	if (m_width == m_depth && m_depth == m_height)
	{
		m_type = "Square";
	}
	else
	{
		m_type = "Rectangular";
	}
	for(int i=0;i<5;i++) 
	{
		m_type = sarray[i];
	}
	
	return m_type;
}

int Box::getWidth()
{
	return m_width;
}

int Box::getDepth()
{
	return m_depth;
}

int Box::getHeight(int heightstore)
{
	return m_height;
}

int Box::getVolume()
{
	m_volume = m_width * m_depth * m_height;
	return m_volume;
}

int Box::getMaxX()
{
	if(xcoords[2]>xcoords[0])
	{
		local_maxx = xcoords[2];
	}
	return local_maxx;
}
int Box::getMaxY()
{		
	if(ycoords[2]>ycoords[0])
	{
		local_maxy = ycoords[2];
	}
	return local_maxy;
}
int Box::getMinX()
{		
	if(xcoords[0]<xcoords[2])
	{
		local_minx = xcoords[2];
	}	
	return local_minx;
}
int Box::getMinY()
{
	if(ycoords[0]<ycoords[2])
	{
		local_minx = xcoords[2];
	}	
	return local_miny;
}
class BoxCollection
{
	public:
		BoxCollection();
		int gettotalVolume();
		void printVolume();
	private:
		int maxX;
		int maxY;
		int minX;
		int minY;
		int totalvolume;
		int btype[5];
};

//-----------------------------------------------------------------------------------------------------------------------------
int main()
{
    int heightstore;
	heightstore = 0;
	int z;
	z =5;
	Box Object[5];
	Box PrintObject;
	string sarray[5];
	for (int i=0; i<5;i++)
    {
		Object[i].setData(heightstore);
		Object[i].getWidth();
		Object[i].getDepth();
		Object[i].getHeight(z);
        Object[i].getType();
		Object[i].getVolume();
        Object[i].print1Box(i+1);
	/*	Object[i].printData(i+1, sarray);
		Object[i].getMaxX();
		Object[i].getMaxY();
		Object[i].getMinX();
		Object[i].getMinY(); */
    }
		// print the results for part 1 and 2;
		
    //declare an array of 5 objects of type Box
    //call a function to load the user input into each object
    //call a function to print results for part #1 and #2
    //call a function to print results for part #3
    //print the results for part #4
	cout << "\n\n\t" << endl;
    cout << "Press the enter key to continue ...";
    cin.get();
    return EXIT_SUCCESS;
}



        Enter X, Y:
0 0


        Enter X, Y:
0 5


        Enter X, Y:
14 5


        Enter X, Y:
14 0


        Enter Height:
5
Box#                     Box Type                          Volume(cu/units)

1                        Rectangular                                    350
// track volume and type; for each int box #i there is a matching string type and a matching int volume.

        Enter X, Y:
0 5


        Enter X, Y:
0 10


        Enter X, Y:
5 10


        Enter X, Y:
5 5


        Enter Height:
5
Box#                     Box Type                          Volume(cu/units)

2                        Square                                         125


        Enter X, Y:
5 5


        Enter X, Y:
5 10


        Enter X, Y:
10 10


        Enter X, Y:
10 5


        Enter Height:
5
Box#                     Box Type                          Volume(cu/units)

3                        Square                                         125
// track volume and type; for each int box #i there is a matching string type and a matching int volume.


        Enter X, Y:
10 7


        Enter X, Y:
10 8


        Enter X, Y:
13 8


        Enter X, Y:
13 7


        Enter Height:
3
Box#                     Box Type                          Volume(cu/units)

4                        Rectangular                                      9


        Enter X, Y:
10 5


        Enter X, Y:
10 7


        Enter X, Y:
15 7


        Enter X, Y:
15 5


        Enter Height:
4
Box#                     Box Type                          Volume(cu/units)

5                        Rectangular                                     40



Press the enter key to continue ...

So i need to basically assign a new class with box#, box type, and box volume calculated above from the previous box class, what can i look up to learn how to do this?

Thanks.
Yet another thread on the same topic - so that's 4 of them now -
Dude, just don't read my threads then. Come on man it's not that serious.
Life isn't that serious. That isn't to say that we shouldn't respect the people who might help us by not wasting their time with duplicate threads.
ok mom
Topic archived. No new replies allowed.