#include #include #include #include #include class Regular_Pyramid { protected: std::string name; double side; double height; double total_area = 1.0; public: static int ostroslupy_duze; Regular_Pyramid() { name = "Pyramid"; side = 1; height = 1; } Regular_Pyramid(std::string name, double side, double height) { this->name = name; this->side = side; this->height = height; } ~Regular_Pyramid() = default; virtual void calculate_area() { /*double triangle_height; triangle_height = sqrt(height*height + 0.25 * side * side); total_area = side * side + 4 * triangle_height * 0.5 * side; std::cout << "Pole powierzchni ostroslupa " << name << " jest rowne: " << total_area << std::endl;*/ } }; class Square_Regular_Pyramid : public Regular_Pyramid { public: void calculate_area() override { /*double triangle_height; triangle_height = sqrt(height*height + 0.25 * side * side); total_area = side * side + 4 * triangle_height * 0.5 * side; std::cout << "Pole powierzchni ostroslupa " << name << " jest rowne: " << total_area << std::endl;*/ total_area = 2 * side * sqrt(height * height + 0.25 * side * side) + side * side; } void operator-(int b) { try { if(side <= 0) throw "Nie mozna zmiejszyc o podana dlugosc"; side = side - b; } catch(const char* e) { std::cout << e << std::endl; } } };