/
ArtT
/
Netology
Обзор
Документация
Войти
/
ArtT
/
Netology
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Part2/Task_2_7_2/Figure.cpp
135 строк
7 KB
ArtT
Добавил седьмое задание
28 ноя 2025, 11:40
28 ноя 2025, 11:40
bbd75f6
Код
Авторство
О чём код?
#include <string> #include "Figure.h" #include "ExceptFigure.h" Figure::Figure(const std::string setName, const int setSidesCount) : name{ setName }, sides_count{ setSidesCount } {}; int Figure::getSidesCount() { return sides_count; } std::string Figure::getName() { return name; } bool Figure::isGood() { return true; } //-----------------------������������-----------------------// int Triangle::get_a() { return a; } int Triangle::get_b() { return b; } int Triangle::get_c() { return c; } int Triangle::get_A() { return A; } int Triangle::get_B() { return B; } int Triangle::get_C() { return C; } std::string Triangle::printInfo() { return this->getName() + ": \n" + "�������: a = " + std::to_string(this->a) + ", b = " + std::to_string(this->b) + ", c = " + std::to_string(this->c) + "\n" + "����: A = " + std::to_string(this->A) + ", B = " + std::to_string(this->B) + ", C = " + std::to_string(this->C); } bool Triangle::isGood() { //������� � ���� ������������, ���������� ������ ����� 3, ����� ����� ����� 180 if (sides_count == 3 && (get_A() + get_B() + get_C() == 180)) return true; else return false; } Triangle::Triangle(std::string setName, int set_a, int set_b, int set_c, int set_A, int set_B, int set_C) : Figure(setName, 3), a{ set_a }, b{ set_b }, c{ set_c }, A{ set_A }, B{ set_B }, C{ set_C } { if (!isGood()) throw ErrorFigure("������ �������� ������ " + this->getName() + ". ����������� �������: ������� � ���� ������������, ���������� ������ ����� 3, ����� ����� ����� 180"); } Triangle::Triangle(int set_a, int set_b, int set_c, int set_A, int set_B, int set_C) : Figure("�����������", 3), a{ set_a }, b{ set_b }, c{ set_c }, A{ set_A }, B{ set_B }, C{ set_C } { if (!isGood()) throw ErrorFigure("������ �������� ������ " + this->getName() + ". ����������� �������: ������� � ���� ������������, ���������� ������ ����� 3, ����� ����� ����� 180"); } RectangularTriangle::RectangularTriangle(int set_a, int set_b, int set_c, int set_A, int set_B) : Triangle("������������� �����������", set_a, set_b, set_c, set_A, set_B, 90) { if (get_C() != 90) throw ErrorFigure("������ �������� ������ " + this->getName() + ". ����������� �������: ���� C ������ ����� 90"); } IsoscelesTriangle::IsoscelesTriangle(int set_a, int set_b, int set_A, int set_B) : Triangle("�������������� �����������", set_a, set_b, set_b, set_A, set_B, set_B) { if(get_a() != get_c() || get_A() != get_C()) throw ErrorFigure("������ �������� ������ " + this->getName() + ". ����������� �������: ������� a � c �����, ���� A � C �����"); } EquilateralTriangle::EquilateralTriangle(int set_a) : Triangle("�������������� �����������", set_a, set_a, set_a, 60, 60, 60) { if (get_a() != get_b() || get_b() != get_c() || get_A() != get_B() || get_B() != get_C() || get_A() != 60) throw ErrorFigure("��� ������� �����, ��� ���� ����� 60"); } //-----------------------------------------------------------// //---------------------����������������---------------------// int Quadrangle::get_a() { return a; } int Quadrangle::get_b() { return b; } int Quadrangle::get_c() { return c; } int Quadrangle::get_d() { return d; } int Quadrangle::get_A() { return A; } int Quadrangle::get_B() { return B; } int Quadrangle::get_C() { return C; } int Quadrangle::get_D() { return D; } std::string Quadrangle::printInfo() { return this->getName() + ": \n" + "�������: a = " + std::to_string(this->a) + ", b = " + std::to_string(this->b) + ", c = " + std::to_string(this->c) + ", d = " + std::to_string(this->d) + "\n" + "����: A = " + std::to_string(this->A) + ", B = " + std::to_string(this->B) + ", C = " + std::to_string(this->C) + ", D = " + std::to_string(this->D); } bool Quadrangle::isGood() { //������� � ���� ������������, ���������� ������ ����� 4, ����� ����� ����� 360 if (sides_count == 4 && (get_A() + get_B() + get_C() + get_D() == 360)) return true; else return false; } Quadrangle::Quadrangle(std::string setName, int set_a, int set_b, int set_c, int set_d, int set_A, int set_B, int set_C, int set_D) : Figure(setName, 4), a{ set_a }, b{ set_b }, c{ set_c }, d{ set_d }, A{ set_A }, B{ set_B }, C{ set_C }, D{ set_D } { if (!isGood()) throw ErrorFigure("������ �������� ������ " + this->getName() + ". ����������� �������: ������� � ���� ������������, ���������� ������ ����� 4, ����� ����� ����� 360"); } Quadrangle::Quadrangle(int set_a, int set_b, int set_c, int set_d, int set_A, int set_B, int set_C, int set_D) : Figure("��������������", 4), a{ set_a }, b{ set_b }, c{ set_c }, d{ set_d }, A{ set_A }, B{ set_B }, C{ set_C }, D{ set_D } { if (!isGood()) throw ErrorFigure("������ �������� ������ " + this->getName() + ". ����������� �������: ������� � ���� ������������, ���������� ������ ����� 4, ����� ����� ����� 360"); } Parallelogram::Parallelogram(std::string setName, int set_a, int set_b, int set_A, int set_B) : Quadrangle(setName, set_a, set_b, set_a, set_b, set_A, set_B, set_A, set_B) { if (get_a() != get_c() || get_b() != get_d() || get_A() != get_C() || get_B() != get_D()) throw ErrorFigure("������ �������� ������ " + this->getName() + ". ����������� �������: ������� a,c � b,d ������� �����, ���� A,C � B,D ������� �����"); } Parallelogram::Parallelogram(int set_a, int set_b, int set_A, int set_B) : Quadrangle("��������������", set_a, set_b, set_a, set_b, set_A, set_B, set_A, set_B) { if (get_a() != get_c() || get_b() != get_d() || get_A() != get_C() || get_B() != get_D()) throw ErrorFigure("������ �������� ������ " + this->getName() + ". ����������� �������: ������� a,c � b,d ������� �����, ���� A,C � B,D ������� �����"); } Rectangle::Rectangle(std::string setName, int set_a, int set_b) : Parallelogram(setName, set_a, set_b, 90, 90) { if (get_A() != get_B() || get_B() != 90) throw ErrorFigure("������ �������� ������ " + this->getName() + ". ����������� �������: ������� a,c � b,d ������� �����, ��� ���� ����� 90"); } Rectangle::Rectangle(int set_a, int set_b) : Parallelogram("�������������", set_a, set_b, 90, 90) { if (get_A() != get_B() || get_B() != 90) throw ErrorFigure("������ �������� ������ " + this->getName() + ". ����������� �������: ������� a,c � b,d ������� �����, ��� ���� ����� 90"); } Square::Square(int set_a) : Rectangle("�������", set_a, set_a) { if (get_a() != get_b()) throw ErrorFigure("������ �������� ������ " + this->getName() + ". ����������� �������: ��� ������� �����, ��� ���� ����� 90"); } Rhomb::Rhomb(int set_a, int set_A, int set_B) : Parallelogram("����", set_a, set_a, set_A, set_B) { if (get_a() != get_b()) throw ErrorFigure("������ �������� ������ " + this->getName() + ". ����������� �������: ��� ������� �����, ���� A,C � B,D ������� �����"); } //-----------------------------------------------------------//