Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- class Circle {
- private:
- static int count;
- int rad;
- double coordX, coordY;
- public:
- Circle() {
- count++;
- this->coordX = 0;
- this->coordY = 0;
- this->rad = 1;
- cout << "Now it's an elementary circle with radius 1" << endl;
- }
- Circle(double coordX, double coordY, int r) {
- count++;
- this->coordX = coordX;
- this->coordY = coordY;
- this->rad = r;
- cout << "Now it's a circle with center in " << "(" << this->coordX << ", " << this->coordY << ") ";
- cout << "and with radius " << this->rad << endl;
- }
- Circle(const Circle& p) {
- count++;
- this->coordX = p.coordX;
- this->coordY = p.coordY;
- this->rad = p.rad;
- }
- friend istream& operator>>(istream& in, Circle c) {
- in >> c.coordX >> c.coordY >> c.rad;
- return in;
- }
- double circleLength() {
- double pi = acos(-1);
- cout << "The length of the " << count << " circle is " << 2 * pi * (this->rad) << endl;
- return 2 * pi * (this->rad);
- }
- double roundSquare() {
- double pi = acos(-1);
- cout << "The square of the " << count << " round is " << pi * pow((this->rad), 2) << endl;
- return pi * pow((this->rad), 2);
- }
- void printEquation() {
- cout << "The equation of this circle is ";
- cout << "(x - " << this->coordX << ")^2 + (y - " << this->coordY << ") = " << pow((this->rad), 2) << endl;
- }
- };
- int Circle::count = 0;
- int main() {
- Circle c1;
- Circle c2(2, 3, 1);
- Circle c3 = c2;
- cout << "Write the information the first circle: ";
- cin >> c1;
- cout << "For c1: Circle length = " << c1.circleLength() << "; Round square = " << c1.roundSquare() << endl;
- c1.printEquation();
- cout << "For c2: Circle length = " << c2.circleLength() << "; Round square = " << c2.roundSquare() << endl;
- c2.printEquation();
- cout << "For c3: Circle length = " << c3.circleLength() << "; Round square = " << c3.roundSquare() << endl;
- c3.printEquation();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement