Create a library to manage representation (not drawing) of objects in 2d and 3d. This library can be seen as a start of a graphics library, but graphics are not part of the task.

Content library must include a minimum of abstract data types (classes) for
- Create, save, and print 2D and 3D points.
- Adding together two points to create a line.
- Create, save, and print 2D and 3D lines.
- Adding together a line and a point or two lines to create a polygon.
- Create, save, and print 2D and 3D polygons.
- Retracting a polygon and a point or a polygon, and a line or two polygons to create a polygon.

All operations to be performed on the objects we create must be made using operators.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <cstdlib>
#include "Polygon2D.h"
#include "Line2D.h"
#include "Point2D.h"
#include "Polygon3D.h"
#include "Line3D.h"
#include "Point3D.h"
using namespace std;

void test2D();
void test3D();

int main(int argc, char** argv) {
    // test 2d shape
    // test 3D shapes
    return 0;

void test2D(){
    // test input stream
    Point2D p[3];
    cout << "Enter 3 2D points ";
    for (int i = 0; i < 3; i++) {
       cin >> p[i];
    // test output stream
    cout << "3 2D points : \n";
    for (int i = 0; i < 3; i++) {
       cout << p[i] << "\n";

    // test addition operator
    cout << "A line from " << p[0] << " to " << p[1] << "\n";
    Line2D l1 = p[0] + p[1];
    cout<< l1 << "\n";
    cout << "A polygon is created with point " << p[2] << " and line " << l1 << "\n" ;
    Polygon2D pl = l1 + p[2];
    cout << pl << "\n";
    // test retracting operator
    cout << "A polygon is created by retracting polygon " << pl << " and point " << p[2] << "\n" ;
    Polygon2D pl2 = pl - p[2];
    cout << pl2 << "\n";
$30.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats