Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- using namespace std;
- class Point {
- public:
- Point(double xX, double yY)
- : x{xX}, y{yY} {
- // empty validation body //
- }
- double x{0.0};
- double y{0.0};
- };
- class Polygon {
- public:
- void addPoint(Point p) {
- int qty{0};
- int item{0};
- cin >> qty;
- for (int i = 1; i <= qty; i += 1) {
- cin >> item;
- points.push_back(item);
- }// push point p into the vector
- }
- Point getPoint(int index) {
- // return the point from the vector at location index
- }
- size_t size() {
- // return the number of points in the vector
- }
- double area() {
- // calculate the area by iterating over the points
- }
- private:
- vector<Point> points{};
- };
- int main()
- {
- Polygon a{}; // define a polygon variable
- a.addPoint()// put points into the polygon
- a.area() // call the area function
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement