Advertisement
Guest User

repl.it - Irregular Polygon Area

a guest
Mar 20th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. class Point {
  8. public:
  9.     Point(double xX, double yY)
  10.     : x{xX}, y{yY} {
  11.         // empty validation body //
  12.     }
  13.  
  14.     double x{0.0};
  15.     double y{0.0};
  16.  
  17. };
  18.  
  19. class Polygon {
  20. public:
  21.     void addPoint(Point p) {
  22.         int qty{0};
  23.         int item{0};
  24.  
  25.         cin >> qty;
  26.         for (int i = 1; i <= qty; i += 1) {
  27.             cin >> item;
  28.             points.push_back(item);
  29.         }// push point p into the vector
  30.     }
  31.  
  32.     Point getPoint(int index) {
  33.         // return the point from the vector at location index
  34.     }
  35.  
  36.     size_t size() {
  37.         // return the number of points in the vector
  38.     }
  39.  
  40.     double area() {
  41.         // calculate the area by iterating over the points
  42.     }
  43.  
  44.  
  45. private:
  46.     vector<Point> points{};
  47.  
  48. };
  49.  
  50. int main()
  51. {
  52.     Polygon a{}; // define a polygon variable
  53.     a.addPoint()// put points into the polygon
  54.     a.area() // call the area function
  55.  
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement