Skip to content

Commit

Permalink
Update Shapes.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
BhJaipal authored Mar 17, 2023
1 parent fc7cb43 commit aa2c19a
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions Shapes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ namespace ThreeD_Shapes {
int len;
int brea;
int hei;
Cuboid(int len, int brea, int hei) {
this->len = len;
this->brea = brea;
this->hei = hei;
Cuboid(int *len, int *brea, int *hei) {
this->len = *len;
this->brea = *brea;
this->hei = *hei;
}
double cubo_tsa() {
return 2* (this->len*this->brea + this->brea*this->hei + this->hei*this->len);
Expand Down Expand Up @@ -40,8 +40,8 @@ namespace ThreeD_Shapes {
class Cube {
public:
int side;
Cube(int side) {
this->side = side;
Cube(int *side) {
this->side = *side;
}
double cube_tsa() {
return 6*this->side*this->side;
Expand Down Expand Up @@ -70,8 +70,8 @@ namespace ThreeD_Shapes {
class Sphere {
public:
int rad;
Sphere(int rad) {
this->rad = rad;
Sphere(int *rad) {
this->rad = *rad;
}
double sphere_sa() {
return 4*22/7* this->rad*this->rad;
Expand All @@ -91,9 +91,9 @@ namespace ThreeD_Shapes {
public:
int radi;
int heig;
Cylinder(int radi, int heig) {
this->radi = radi;
this->heig = heig;
Cylinder(int *radi, int *heig) {
this->radi = *radi;
this->heig = *heig;
}
double cyl_tsa() {
return 2*22/7* this->radi* (this->heig + this->radi);
Expand Down Expand Up @@ -126,30 +126,30 @@ void main_execution() {
int radius;
cout << "Enter radius: ";
cin >> radius;
ThreeD_Shapes::Sphere mySphere(radius);
ThreeD_Shapes::Sphere mySphere(&radius);
mySphere.execute();
}

else if (choice == 2) {
int sides;
cout << "Enter side: ";
cin >> sides;
ThreeD_Shapes::Cube mycube(sides);
ThreeD_Shapes::Cube mycube(&sides);
mycube.execute();
}

else if (choice == 3) {
int length; cout << "Enter length: "; cin >> length;
int breadth; cout << "Enter breadth: "; cin >> breadth;
int height; cout << "Enter height: "; cin >> height;
ThreeD_Shapes::Cuboid mycuboid(length, breadth, height);
ThreeD_Shapes::Cuboid mycuboid(&length, &breadth, &height);
mycuboid.execute();
}

else if (choice == 4) {
int radii; cout << "Enter radius: "; cin >> radii;
int heigh; cout << "Enter height: "; cin >> heigh;
ThreeD_Shapes::Cylinder mycylinder(radii, heigh);
ThreeD_Shapes::Cylinder mycylinder(&radii, &heigh);
mycylinder.execute();
}

Expand All @@ -172,4 +172,4 @@ void main_execution() {
int main() {
main_execution();
return 0;
}
}

0 comments on commit aa2c19a

Please sign in to comment.