Untitled

Mar 25th, 2020
142
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <iostream>
2. #include <cmath>
3.
4. using namespace std;
5.
6. class Circle {
7. private:
8.     static int count;
10.     double coordX, coordY;
11. public:
12.     Circle() {
13.         count++;
14.         this->coordX = 0;
15.         this->coordY = 0;
17.         cout << "Now it's an elementary circle with radius 1" << endl;
18.     }
19.     Circle(double coordX, double coordY, int r) {
20.         count++;
21.         this->coordX = coordX;
22.         this->coordY = coordY;
24.         cout << "Now it's a circle with center in " << "(" << this->coordX << ", " << this->coordY << ") ";
26.     }
27.     Circle(const Circle& p) {
28.         count++;
29.         this->coordX = p.coordX;
30.         this->coordY = p.coordY;
32.     }
33.
34.     friend istream& operator>>(istream& in, Circle c) {
35.         in >> c.coordX >> c.coordY >> c.rad;
36.         return in;
37.     }
38.
39.     double circleLength() {
40.         double pi = acos(-1);
41.         cout << "The length of the " << count << " circle is " << 2 * pi * (this->rad) << endl;
42.         return 2 * pi * (this->rad);
43.     }
44.
45.     double roundSquare() {
46.         double pi = acos(-1);
47.         cout << "The square of the " << count << " round is " << pi * pow((this->rad), 2) << endl;
48.         return pi * pow((this->rad), 2);
49.     }
50.
51.     void printEquation() {
52.         cout << "The equation of this circle is ";
53.         cout << "(x - " << this->coordX << ")^2 + (y - " << this->coordY << ") = " << pow((this->rad), 2) << endl;
54.     }
55. };
56.
57. int Circle::count = 0;
58. int main() {
59.     Circle c1;
60.     Circle c2(2, 3, 1);
61.     Circle c3 = c2;
62.
63.     cout << "Write the information the first circle: ";
64.     cin >> c1;
65.     cout << "For c1: Circle length = " << c1.circleLength() << "; Round square = " << c1.roundSquare() << endl;
66.     c1.printEquation();
67.
68.     cout << "For c2: Circle length = " << c2.circleLength() << "; Round square = " << c2.roundSquare() << endl;
69.     c2.printEquation();
70.
71.     cout << "For c3: Circle length = " << c3.circleLength() << "; Round square = " << c3.roundSquare() << endl;
72.     c3.printEquation();
73.
74.     return 0;
75. }