Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Point{
- private:
- int x, y;
- public:
- void readData ()
- {
- cin >> x;
- cin >> y;
- }
- int getx () { return x;}
- int gety () { return y;}
- };
- class Rectangle{
- private:
- class Point tr, bl;
- public:
- void setPoint ()
- {
- cout << "Top-Right Point: ";
- tr.readData();
- cout << "Bottom-Left Point: ";
- bl.readData();
- }
- int getx1() { return tr.getx();}
- int getx2() { return bl.getx();}
- int gety1() { return tr.gety();}
- int gety2() { return bl.gety();}
- };
- void area (Rectangle X);
- main()
- {
- class Rectangle R;
- cout << "This Program Can Calculate the Area of A Rectangle Using 2 (Cartesian) Co-Ordinates" << endl;
- cout << "Enter Points" << endl;
- R.setPoint();
- area (R);
- return 0;
- }
- void area (Rectangle X)
- {
- int A, x1, x2, y1, y2;
- x1 = X.getx1();
- x2 = X.getx2();
- y1 = X.gety1();
- y2 = X.gety2();
- A = (x1 - x2) * (y1 - y2);
- cout << "Area is: " << A;
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement