Kat H.

asked • 03/31/21

Replace YOUR_CODE with code that will move Point p1 10 units to the right and 3 units down and Point p2 2 units to the left and 5 units up.

Read the provided code for the Point class that represents a point on a standard Cartesian plane. Then read the provided code in main.


Replace YOUR_CODE with code that will move Point p1 10 units to the right and 3 units down and Point p2 2 units to the left and 5 units up.


Code:


#include <iostream>

using namespace std;


class Point {

private:

double x;

double y;


public:

Point() {

x = 0;

y = 0;

}


double getX() {

return x;

}

double getY() {

return y;

}

void translate(double deltaX, double deltaY) {

x += deltaX;

y += deltaY;

}

};


int main()

{

Point p1;

Point p2;


//Do not modify anything on or above the line below this

//YOUR_CODE_BELOW


//YOUR_CODE


//YOUR_CODE_ABOVE

//Do not modify anything on or below the line above this


cout << p1.getX() << " " << p1.getY() << endl;

cout << p2.getX() << " " << p2.getY() << endl;

}

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.