// figures.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы. // #pragma once #include #include "Triangle.h" #include "Rectangle.h" #include "polygon.h" #include "circle.h" #include "elipse.h" using namespace std; void chck_trinagle(); void chck_rectangle(); void chck_polygon(); void chck_circle(); void chck_elipse(); void chck_polimorph(); int main() { //chck_trinagle(); //chck_rectangle(); //chck_polygon(); //chck_circle(); //chck_elipse(); chck_polimorph(); } void chck_trinagle() { ////треугольник Triangle T; T = Triangle(Point(0,0),Point(0,5),Point(5,0)); T.name(); cout << T.calc_perimeter() << '\t' << T.calc_area() << endl; } void chck_rectangle() { //прямоугольник Rectangle R; R = Rectangle(0, 0, 0, 5, 5, 5, 5, 0); R.name(); cout << R.calc_perimeter() << '\t' << R.calc_area() << endl; } void chck_polygon() { vector A; A.push_back(0); A.push_back(0); A.push_back(5); A.push_back(0); A.push_back(5); A.push_back(5); A.push_back(0); A.push_back(5); Polygon p; p = Polygon(A); p.name(); cout << p.calc_area() << "\t" << p.calc_perimeter() << endl; } void chck_circle() { Point c = Point(0, 0); int radius = 5; circle c1, c2; c1 = circle(c, radius); c2 = circle(0, 0, radius); c1.name(); c2.name(); cout << "c1 \t" << c1.calc_area() << '\t' << c1.calc_perimeter() << endl; cout << "c2 \t" << c2.calc_area() << '\t' << c2.calc_perimeter() << endl; } void chck_elipse() { Point c = Point(0, 0); int a = 10, b = 20; elipse el1,el2; el1 = elipse(c, a, b); el2 = elipse(0,0, a, b); el1.name(); el2.name(); cout << "el1 \t" << el1.calc_area() << '\t' << el1.calc_perimeter() << endl; cout << "el2 \t" << el2.calc_area() << '\t' << el2.calc_perimeter() << endl; } void chck_polimorph() { vector figures; figures.push_back(new Triangle(3, 4, 5)); figures.push_back(new circle(0, 0, 5)); figures.push_back(new Rectangle(2, 5)); figures.push_back(new elipse(0, 0, 4, 5)); vector A; A.push_back(0); A.push_back(0); A.push_back(5); A.push_back(0); A.push_back(5); A.push_back(5); A.push_back(0); A.push_back(5); figures.push_back(new Polygon(A)); for (int i = 0; i < figures.size(); i++) { figures[i]->name(); cout << "P=" << figures[i]->calc_area() << "\t S=" << figures[i]->calc_perimeter() << endl; } }