49 lines
831 B
C++
49 lines
831 B
C++
|
|
||
|
#include "shapes.h"
|
||
|
|
||
|
|
||
|
double& Cube::operator() (int i){
|
||
|
try {
|
||
|
if(i==1)
|
||
|
return L;
|
||
|
if (i==2)
|
||
|
return W;
|
||
|
if (i==3)
|
||
|
return H;
|
||
|
if (i<1 || i > 3)
|
||
|
throw(i);
|
||
|
}
|
||
|
catch(int i){
|
||
|
std::cout << "out of index" << i << "\n";
|
||
|
exit(0);
|
||
|
}
|
||
|
return tmp;
|
||
|
}
|
||
|
|
||
|
|
||
|
Cube::Cube(double _L , double _W , double _H, long int _N ):N(_N){
|
||
|
SetL(_L);
|
||
|
Data = new double[N];
|
||
|
Data[0] = _L;
|
||
|
//std::cout << "Constructor was run!\n";
|
||
|
}
|
||
|
|
||
|
|
||
|
Cube::Cube(const Cube &c){
|
||
|
L = c.L;
|
||
|
W = c.W;
|
||
|
H = c.H;
|
||
|
N = c.N;
|
||
|
Data = new double[N];
|
||
|
for (int i{0}; i < N ; i++ )
|
||
|
Data[i] = c.Data[i];
|
||
|
}
|
||
|
|
||
|
void Cube::SetL(double _L){
|
||
|
L = _L;
|
||
|
}
|
||
|
|
||
|
const double& Cube::GetL() {
|
||
|
return L;
|
||
|
}
|