Week 1.pdf Aw

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Week 1

KARBALA UNIVERSITY
COLLEGE OF CS&IT
IT DEPARTMENT
STUDENT:YOUSF MOHAMMED
TO: DR. Meeras.s
Subject:OOP
using namespace std;
class GeometricShape {
public:
string shapeName;
void setShapeName(string shapename1) {
shapeName=shapename1; } };

class Trigon:public GeometricShape {


public:
double base,perpendicular,hypotenuse;

Trigon() { base=1.0; perpendicular=1.0;hypotenuse=1.0;

} Trigon(double base1,double perpendicular1,double hypotenuse1) {

base=base1; perpendicular=perpendicular1; hypotenuse=hypotenuse1; }

void setbase(double base1) {base=base1;}

void setperpendicular(double perpendicular1){perpendicular=perpendicular1;}

void sethypotenuse(double hypotenuse1) {

hypotenuse=hypotenuse1; }
}
double getbase(){

return base;}

double getperpendicular() {return perpendicular;}

double gethypotenuse() { return hypotenuse; }

double displayArea() { return (base*perpendicular)/2; } };

int main() {

Trigon obj(1,2,3);
obj.setShapeName("triangle");
Trigon obj1;
obj1.setShapeName("triangle");

Trigon obj2;obj2.setbase(1);

obj2.sethypotenuse(2);obj2.setperpendicular(3);

obj2.setShapeName("triangle");

cout<<"First area:"<<obj.displayArea()<<endl;
cout<<"Second area:"<<obj1.displayArea()<<endl;
cout<<"Third area:"<<obj2.displayArea()<<endl;
return 0;

You might also like