Escolar Documentos
Profissional Documentos
Cultura Documentos
#include <iostream>
using namespace std;
class CDimensions //class
{
public: //Encapsulation
float width,length,height,fourthdim;
int oper;
CDimensions(); //Costructor
};
CDimensions::CDimensions() //Scope resolution operator
::
{
width=1;
length=1;
height=1;
fourthdim=1;
}
if(oper==1)
circarea(fourthdim);
else if(oper==2)
circumf(fourthdim);
else
cout<<"You have choosen WRONG choice \n";
}
};
if(oper==1)
rectarea(length,width);
else if(oper==2)
rectcircum(length,width);
else
cout<<"You have choosen WRONG choice \n";
}
};
class CTriangle: public CDimensions
{
public:
CTriangle()
{
cout<<"Enter base length\n";
cin>>length;
cout<<"Enter Height\n";
cin>>width;
cout<<"Select operation\n";
cout<<"1.area\n";
cout<<"2.cicumference\n";
cin>>oper;
if(oper==1)
triarea(length,width);
else if(oper==2)
tricircum();
else
cout<<"You have choosen WRONG choice \n";
}
void triarea(float len,float heig)
{
cout<<"Triangle Area is: "<< 0.5*len*heig<<'\n';
}
void tricircum()
{
cout<<"Enter 3 sides value\n";
cin>>length>>width>>height;
CUnknow()
{
cout<<"How many dimension data U have?\n";
cin>>n;
switch (n)
{
case 1:
{
cout<<"Which one is best suits for ur object\n";
cout<<"1.Circle\n";
cout<<"2.square\n";
cin>>ch;
if(ch==1)
CCircle cir; //friend class object creation
else
CRect squ(1); //friend class object creation
break;
}
case 2:
{
CRect rect;
break;
}
case 3:
{
CTriangle tri;
break;
}
default:
cout<<"Sorry for inconvience we are not able to idendify the shape\n ";
}
}
};
int main ()
{
int choice;
int shape=0;
cout<<"This application is for geomentric calculation"<<endl;
cout<<"Choose your Geomentric"<<endl;
do
{
cout<<"----------------\nChoose Shape"<<endl;
cout<<"1.Circle \n";
cout<<"2.Square \n";
cout<<"3.Rectangle \n";
cout<<"4.Triangle \n";
cout<<"5.Don't Know the Shape \n";
cin>>shape;
switch (shape)
{
case 1:
{
CCircle cir; //Object creation
break;
}
case 2:
{
CRect squ(1); //Object will parametrized constructor
break;
}
case 3:
{
CRect rect; //Object will calldefault constructor
break;
}
case 4:
{
CTriangle tri;
break;
}
case 5:
{
CUnknow element;
break;
}
default:
cout<<"Sorry for inconvience u selected wrong option\n";
}while(1);
return 0;
}