Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include"figure.h"
- using namespace std;
- class VolumFigure {
- public:
- virtual int volume() = 0;
- virtual int side_area() = 0;
- virtual int full_area() = 0;
- virtual int basis_area() = 0;
- virtual ~VolumFigure() {};
- };
- class Prism :public VolumFigure {
- protected:
- Polygon* basis;
- int height;
- public:
- Prism() :basis(nullptr), height(0) {}
- Prism(Polygon* p_basis, int p_height) :basis(p_basis), height(p_height) {}
- Prism(const Prism& p) :basis(p.basis), height(p.height) {}
- int volume(){
- return basis->shape_area() * height;
- }
- int side_area() {
- return basis->shape_perimetr() * height;
- }
- int full_area() {
- return 2 * basis->shape_area() + side_area();
- }
- int basis_area() {
- return basis->shape_area();
- }
- friend ostream& operator<<(ostream& out, const Prism& p) {
- out << "Prism basis is " << p.basis->get_shape() << "Height:" << p.height << "cm" << endl;
- return out;
- }
- /*friend istream& operator>>(istream& in, Prism& p) {
- in >> p.basis;
- in >> p.height;
- return in;
- }*/
- };
- class Cube : public VolumFigure {
- protected:
- Square* basis;
- public:
- Cube() :basis(0) {}
- Cube(Square* c_basis) :basis(c_basis) {}
- Cube(const Cube& c) :basis(c.basis) {}
- int volume() {
- return pow(basis->get_diagonal(), 3);
- }
- int side_area() {
- return (basis->shape_area() * 4);
- }
- int full_area() {
- return (pow(basis->get_diagonal(),2)*6);
- }
- int basis_area() {
- return basis->shape_area();
- }
- friend ostream& operator<<(ostream& out, const Cube& c) {
- out << c.basis->get_shape()<< endl;
- return out;
- }
- /*friend istream& operator>>(istream& in, Cube& c) {
- in >> c.basis;
- return in;
- }*/
- };
- class Cylinder : public VolumFigure {
- protected:
- Circle* basis;
- int height;
- public:
- Cylinder() :basis(nullptr), height(0) {}
- Cylinder(Circle* c_basis, int c_height) :basis(c_basis), height(c_height) {}
- Cylinder(const Cylinder& c) :basis(c.basis), height(c.height) {}
- int volume() {
- return (basis->shape_area() * height);
- }
- int side_area() {
- return basis->shape_perimetr() * height;
- }
- int full_area() {
- return 2 * basis->shape_perimetr() + side_area();
- }
- int basis_area() {
- return basis->shape_area();
- }
- friend ostream& operator<<(ostream& out, const Cylinder& c) {
- out << "Cylinder basis is " << c.basis->get_shape() << "Height:" << c.height << "cm" << endl;
- return out;
- }
- /*friend istream& operator>>(istream& in, Cylinder& c) {
- in >> c.basis;
- in >> c.height;
- return in;
- }*/
- };
- class Cone : public Cylinder {
- public:
- Cone() {}
- Cone(Circle* c_basis, int c_height) :Cylinder(c_basis, c_height) {}
- Cone(const Cone& c) :Cylinder(c) {}
- int volume() {
- return (basis->shape_area() * height) / 3;
- }
- int side_area() {
- return 3, 14 * basis->get_radius() * sqrt(pow(height, 2) - pow(basis->get_radius(), 2));
- }
- int full_area() {
- return basis->shape_area() + side_area();
- }
- int basis_area() {
- return basis->shape_area();
- }
- friend ostream& operator<<(ostream& out, const Cone& c) {
- out << "Cone basis is " << c.basis->get_shape() << "Height:" << c.height << "cm" << endl;
- return out;
- }
- /*friend istream& operator>>(istream& in, Cone& c) {
- in >> c.basis;
- in >> c.height;
- return in;
- }*/
- };
- class Ball :public VolumFigure {
- protected:
- Circle* basis;
- public:
- Ball() :basis(0) {}
- Ball(Circle* b_basis) :basis(b_basis) {}
- Ball(const Ball& b) :basis(b.basis) {}
- int volume() {
- return 3, 14 * (4 / 3) * pow(basis->get_radius(), 3);
- }
- int side_area() {
- return 4 * 3, 14 * pow(basis->get_radius(), 2);
- }
- int full_area() {
- return side_area();
- }
- int basis_area() {
- return basis->shape_area();
- }
- friend ostream& operator<<(ostream& out, const Ball& b) {
- out << "Bole basis is " << b.basis->get_shape() << endl;
- return out;
- }
- /*friend istream& operator>>(istream& in, Ball& b) {
- in >> b.basis;
- return in;
- }*/
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement