CPP 실습예제

실습과제 모음 2014. 1. 21. 14:45 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

#include <iostream>

using namespace std;

class Line

{

public:

double startX;

double startY;

double endX;

double endY;

};


class GeometricObject

{

public:

Line line1;

Line line2;


GeometricObject()

{

line1.startX = 0;

line1.startY = 0;

line1.endX = 0;

line1.endY = 0;

line2.startX = 0;

line2.startY = 0;

line2.endX = 0;

line2.endY = 0;

}

GeometricObject(Line a, Line b)

{

line1 = a;

line2 = b;

}

void setLine1(Line a)

{

line1 = a;

}

void setLine2(Line a)

{

line2 = a;

}

Line getLine1()

{

return line1;

}

Line getLine2()

{

return line2;

}

virtual double AreaCalculation() = 0;

virtual double Compute() = 0;

};

class Isosceles : public GeometricObject

{

public:

double area;

double side;


Isosceles()

{

line1.startX = 0;

line1.startY = 0;

line1.endX = 0;

line1.endY = 0;

line2.startX = 0;

line2.startY = 0;

line2.endX = 0;

line2.endY = 0;

area = 0;

side = 0;

}

Isosceles(Line a , Line b)

{

line1 = a;

line2 = b;

area = 0;

side = 0;

}

double AreaCalculation( )

{


return 0.0;

}

double Compute( )

{

return 0.0;

}

void setArea(double a)

{

area = a;

}

void setSide(double a)

{

side = a;

}

double getArea()

{

return area;

}

double getSide()

{

return side;

}

};


int main()

{

Line l1;

l1.startX = 15;

l1.startY = 0;

l1.endX = 15;

l1.endY = 30;

Line l2;

l2.startX = 0;

l2.startY = 30;

l2.endX = 30;

l2.endY = 30;

Isosceles is(l1,l2);

cout << is.AreaCalculation() << endl;

return 0;

}



'실습과제 모음' 카테고리의 다른 글

별 찍기 예제 #3  (0) 2014.03.29
별 찍기 예제 #2  (0) 2014.03.29
CPP GeometricObject  (0) 2014.01.21
cpp 실습  (0) 2014.01.15
CPP 실습  (0) 2014.01.15