Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- class punkt{
- private:
- double x_, z_, y_;
- public:
- punkt() :x_(0), z_(0), y_(0) {};
- punkt(double xx, double yy, double zz) : x_(xx), z_(zz), y_(yy) {};
- double& x(){return x_; };
- double& y() { return y_; };
- double& z() { return z_; };
- const double& x() const { return x_; };
- const double& y() const { return y_; };
- const double& z() const { return z_; };
- };
- class prostokat {
- private:
- double a_, b_;
- punkt p1;
- public:
- prostokat() : a_(0), b_(0), p1() {};
- prostokat(const double& x, const double& y, const double& z, const double& a, const double& b) : a_(a), b_(b), p1(x, y, z) {};
- prostokat(const punkt& p, const double& a, const double& b) : p1(p), a_(a), b_(b) {};
- double& x() { return p1.x(); };
- double& y() { return p1.y(); };
- double& z() { return p1.z(); };
- double& a() { return a_; };
- double& b() { return b_; };
- const double& x() const { return p1.x(); };
- const double& y() const { return p1.y(); };
- const double& z() const { return p1.z(); };
- const double& a() const { return a_; };
- const double& b() const { return b_; };
- double pole() const {return a_ * b_; };
- };
- class graniastoslup {
- private:
- double h_;
- prostokat prstk;
- public:
- graniastoslup(): h_(0), prstk() {};
- graniastoslup(const double& xx, const double& yy, const double& zz, const double& a, const double& b, const double& h) : h_(h), prstk(xx, yy, zz, a, b) {};
- graniastoslup(const punkt punkt, const double& a, const double& b, const double& h) : prstk(punkt, a, b), h_(h) {};
- graniastoslup(const prostokat pr, double h) : h_(h), prstk(pr) {};
- const double& x() const{ return prstk.x(); };
- const double& y() const{ return prstk.y(); };
- const double& z() const{ return prstk.z(); };
- const double& a() const {return prstk.a();};
- const double& b() const { return prstk.b(); };
- const double& h() const { return h_; };
- double& x() { return prstk.x(); };
- double& y() { return prstk.y(); };
- double& z() { return prstk.z(); };
- double& a() { return prstk.a(); };
- double& b() { return prstk.b(); };
- double& h() { return h_; };
- double objetosc() const{ return prstk.pole() * h_; };
- };
- int main() {
- punkt p1, p2(1, 2, 3);
- const punkt p3(1.1, 2.2, 3.3);
- cout << p3.x() << '\t' << p3.y() << '\t' << p3.z() << endl;
- p1.x() = 1; p1.y() = 10; p1.x() = 100;
- cout << p1.x() << '\t' << p1.y() << '\t' << p1.z() << endl;
- prostokat pr1, pr2(1, 2, 3, 10.5, 20.5);
- const prostokat pr3(p2, 5, 5);
- cout << pr3.x() << '\t' << pr3.y() << '\t' << pr3.z() << '\n' << pr3.a() << '\t' << pr3.b() << endl;
- cout << pr3.pole() << endl;
- pr1.x() = 2; pr1.y() = 20; pr1.x() = 200; pr1.a() = 10; pr1.b() = 10;
- cout << pr1.x() << '\t' << pr1.y() << '\t' << pr1.z() << '\n';
- cout << pr1.a() << '\t' << pr1.b() << "\n";
- cout << pr1.pole() << endl;
- graniastoslup g1, g2(1, 2, 3, 10.5, 20.5, 30.5), g3(p2, 100, 200, 300);
- const graniastoslup g4(pr3, 5);
- cout << g4.x() << '\t' << g4.y() << '\t' << g4.z() << '\n'
- << g4.a() <<'\t' << g4.b() << '\t' << g4.h() << '\n'
- << g4.objetosc() << endl;
- g1.a() = 10; g1.b() = 10; g1.h() = 10;
- cout << g1.x() << '\t' << g1.y() << '\t' << g1.z() << '\n'
- << g1.a() << '\t' << g1.b() << '\t' << g1.h() << '\n'
- << g1.objetosc() << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement