Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- class Dot
- {
- private:
- double x;
- double y;
- public:
- void set_x(double x) {
- this->x = x;
- }
- void set_y(double y) {
- this->y = y;
- }
- double get_x() {
- return this->x;
- }
- double get_y() {
- return this->y;
- }
- Dot(double x, double y) {
- this->x = x;
- this->y=y;
- }
- Dot() {
- this->x = 0;
- this->y = 0;
- }
- void print() {
- cout << "X: " << this->x << "Y: " << this->y << endl;
- }
- void make_dot_input() {
- cout << "Enter X: ";
- cin >> this->x;
- cout << "Enter Y: ";
- cin >> this->y;
- cout << endl;
- }
- double how_far(Dot A, Dot B) {
- double k = (pow((B.get_x() - A.get_x()), 2) + pow((B.get_y() - A.get_y()), 2));
- return sqrt(k);
- }
- };
- class Cilindr {
- protected:
- Dot centre;
- Dot dot_in_circle;
- double height;
- public:
- void set_centre(Dot A) {
- this->centre = Dot(A.get_x(), A.get_y());
- }
- void set_dot_in_circle(Dot A) {
- this->dot_in_circle = Dot(A.get_x(), A.get_y());
- }
- void set_height(double h) {
- this->height = h;
- }
- Dot get_centre() {
- return this->centre;
- }
- Dot get_dot_in_cirle() {
- return this->dot_in_circle;
- }
- double get_height() {
- return this->height;
- }
- Cilindr() {
- this->centre = Dot();
- this->dot_in_circle = Dot();
- this->height = 1;
- }
- Cilindr(Dot centre, Dot dot_in_circle, double h) {
- this->centre = centre;
- this->dot_in_circle = dot_in_circle;
- this->height = h;
- }
- void print() {
- cout << "Cilindr" << endl;
- centre.print();
- dot_in_circle.print();
- cout << "Height: " << this->height << endl;
- }
- void make_cilindr_input() {
- cout << "Enter height of new cilindr: ";
- cin >> this->height;
- centre.make_dot_input();
- dot_in_circle.make_dot_input();
- cout << endl;
- }
- double square_osnovaniya() {
- return pow(Dot().how_far(centre, dot_in_circle), 2) * 3.14;
- }
- double volume() {
- return this->square_osnovaniya() * this->height;
- }
- double square_bok_pov() {
- return 2 * 3.14 * Dot().how_far(centre, dot_in_circle) * height;
- }
- double len_circle() {
- return 2 * 3.14 * Dot().how_far(centre, dot_in_circle);
- }
- };
- int main()
- {
- Cilindr A = Cilindr(Dot(0, 0), Dot(0, 1), 3);
- A.print();
- cout << " SQUARE OSN | Volume | Bok pov | Len " << endl;
- cout <<" " << A.square_osnovaniya() << " " << A.volume() << " " << A.square_bok_pov() << " " << A.len_circle() << endl;
- A.make_cilindr_input();
- A.print();
- cout << " SQUARE OSN | Volume | Bok pov | Len " << endl;
- cout << " " << A.square_osnovaniya() << " " << A.volume() << " " << A.square_bok_pov() << " " << A.len_circle() << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement