Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <cstdlib>
- using namespace std;
- class Okrag{
- private:
- double x_position;
- double radius;
- public:
- Okrag();
- Okrag(double x, double r){
- x_position = x;
- radius = r;
- cout << "Jestem okregiem z punktu (" << x_position << ", 0) o promieniu " << radius << "." << endl;
- }
- ~Okrag(){
- cout << "Okrag z punktu (" << x_position << ", 0) o dlugosci " << circleLength() << " znika." << endl;
- }
- double getX(){return x_position;}
- double getRadius(){return radius;}
- void setX(double newX){x_position = newX;}
- void setRadius(double newRadius){if(newRadius >= 0) radius = newRadius;}
- double circleLength();
- };
- double Okrag::circleLength(){
- return 2*M_PI*radius;
- }
- int main(){
- double okr1X;
- double okr2X;
- double okr1Radius;
- double okr2Radius;
- cout << "Podaj wsp. X okregu 1: ";
- cin >> okr1X;
- cout << "Podaj promien okregu 1: ";
- cin >> okr1Radius;
- cout << "Podaj wsp. X okregu 2: ";
- cin >> okr2X;
- cout << "Podaj promien okregu 2: ";
- cin >> okr2Radius;
- Okrag* o1 = new Okrag(okr1X, okr1Radius);
- Okrag* o2 = new Okrag(okr2X, okr2Radius);
- cout << "Okrag o1 miesci sie " << int(o2->circleLength()/o1->circleLength()) << " razy." << endl;;
- delete o1;
- delete o2;
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement