Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(C++ program) Any idea how to do the moveBy function? ---> https://cl.ly/951c84ad25fb full code: #include #include using namespace std; class Point { private: int x

(C++ program) Any idea how to do the moveBy function? ---> https://cl.ly/951c84ad25fb

full code:

#include #include

using namespace std;

class Point { private: int x = 0; int y = 0; public: Point(int xVal, int yVal) { moveBy(xVal, yVal); } string toString() { return to_string(x) + ", " + to_string(y); } void moveBy(int xVal, int yVal) { x += xVal; y += yVal; } };

class Segment { public: string toString() { return p1->toString() + " to " + p2->toString(); }

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

Segment(Point *p3, Point *p4) { p1 = p3; p2 = p4; } private: Point *p1; Point *p2;

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

int main() { Point A(0, 0); Point B(4, 4);

Segment s1(&A, &B);

cout << s1.toString() << endl; s1.moveBy(1, 1); cout << s1.toString() << endl; s1.moveBy(0, -2); cout << s1.toString() << endl; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

What are the main differences between rigid and flexible pavements?

Answered: 1 week ago

Question

What is the purpose of a retaining wall, and how is it designed?

Answered: 1 week ago

Question

How do you determine the load-bearing capacity of a soil?

Answered: 1 week ago

Question

what is Edward Lemieux effect / Anomeric effect ?

Answered: 1 week ago