This course teaches how to install and configure Windows Server 2012 R2. It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

My assignment is to write a definition of a class named Point used to store and manipulate the location of a point in a plane. You need to declare and implement the following member functions:

1 - a member function set that sets the private data after an object of this class is created.

2 - a member function to move the point by an amount along the vertical and horizontal directions specified by the first and second arguments.

3 - a member function to rotate the point by 90 degrees clockwise around the origin.

4 - two const inspector functions to retrieve the current coordinates of the point.

Embed your class in a test program that requests data for several points from the user, creates the points, then exercises the member functions.

Here is my code below: I am just trying to get it to work. I can work out the test program later..

Right now I am getting 3 errors.. Please help...

Code:

#include <iostream>

#include <cstdlib>

using namespace std;

class Point

{

public:

Point();

//member functions

void setPoints(double& set_x, double& set_y);

//void setPointY(double set_y);

void movePoints(double& move_x, double& move_y);

void rotatePoints();

double get_x()const;

double get_y()const;

//member variables

private:

double x, y;

double adjY, adjX;

};

int main()

{

double x1, y1;

setPoints (x1, y1);

movePoints(x1, y1);

rotatePoints();

return 0;

}

Point::Point()

{

x=0;

y=0;

}

void Point::setPoints(double& new_x, double& new_y)

{

x = new_x;

y = new_y;

cout << "Enter the X coordinate:" << endl;

cin >> x;

cout << "Enter the Y coordinate:" << endl;

cin >> y;

}

void Point::movePoints(double& move_x, double& move_y)

{

x = x+move_x;

y = y+move_y;

cout << "Enter the new X coordinate:" << endl;

cin >> x;

cout << "Enter the new Y coordinate:" << endl;

cin >> y;

cout << "The new position of the coordinates is:"<<endl;

cout << get_x()<< ""<<get_y()<<endl;

}

void Point::rotatePoints()

{

adjX = -y;

adjY = x;

cout << "Enter the adjusted x coordinate:" <<endl;

cin >> adjX;

cout << "Enter the adjusted y coordinate:" <<endl;

cin >> adjY;

}

double Point::get_x()const

{

return x;

}

double Point::get_y()const

{

return y;

}

1 - a member function set that sets the private data after an object of this class is created.

2 - a member function to move the point by an amount along the vertical and horizontal directions specified by the first and second arguments.

3 - a member function to rotate the point by 90 degrees clockwise around the origin.

4 - two const inspector functions to retrieve the current coordinates of the point.

Embed your class in a test program that requests data for several points from the user, creates the points, then exercises the member functions.

Here is my code below: I am just trying to get it to work. I can work out the test program later..

Right now I am getting 3 errors.. Please help...

Code:

#include <iostream>

#include <cstdlib>

using namespace std;

class Point

{

public:

Point();

//member functions

void setPoints(double& set_x, double& set_y);

//void setPointY(double set_y);

void movePoints(double& move_x, double& move_y);

void rotatePoints();

double get_x()const;

double get_y()const;

//member variables

private:

double x, y;

double adjY, adjX;

};

int main()

{

double x1, y1;

setPoints (x1, y1);

movePoints(x1, y1);

rotatePoints();

return 0;

}

Point::Point()

{

x=0;

y=0;

}

void Point::setPoints(double& new_x, double& new_y)

{

x = new_x;

y = new_y;

cout << "Enter the X coordinate:" << endl;

cin >> x;

cout << "Enter the Y coordinate:" << endl;

cin >> y;

}

void Point::movePoints(double& move_x, double& move_y)

{

x = x+move_x;

y = y+move_y;

cout << "Enter the new X coordinate:" << endl;

cin >> x;

cout << "Enter the new Y coordinate:" << endl;

cin >> y;

cout << "The new position of the coordinates is:"<<endl;

cout << get_x()<< ""<<get_y()<<endl;

}

void Point::rotatePoints()

{

adjX = -y;

adjY = x;

cout << "Enter the adjusted x coordinate:" <<endl;

cin >> adjX;

cout << "Enter the adjusted y coordinate:" <<endl;

cin >> adjY;

}

double Point::get_x()const

{

return x;

}

double Point::get_y()const

{

return y;

}

Experts Exchange Solution brought to you by

Enjoy your complimentary solution view.

Get every solution instantly with Premium.
Start your 7-day free trial.

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

```
int main()
{
double x1, y1;
Point p;
p.setPoints (x1, y1);
p.movePoints(x1, y1);
p.rotatePoints();
return 0;
}
```

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trialerror C3861: 'setPoints': identifier not found

It's so straightforward that there's no need for calculations even.

Rotate point (1, 2) 90 degrees clockwise around the origin to get (2, -1).

Rotate point (2, -1) 90 degrees clockwise around the origin to get (-1, -2).

Rotate point (-1, -2) 90 degrees clockwise around the origin to get (-2, 1).

Rotate point (-2, 1) 90 degrees clockwise around the origin to get (1, 2).

See a pattern ? ;)

Take a closer look at what exactly you are doing in the move function. What are the I/O lines doing there ?

Editors IDEs

From novice to tech pro — start learning today.

Experts Exchange Solution brought to you by

Enjoy your complimentary solution view.

Get every solution instantly with Premium.
Start your 7-day free trial.

And what would those errors be ?