Question
(Using C++)The type Point is a fairly simple data type, but under another name (the template class pair) this data type is defined and used
(Using C++)The type Point is a fairly simple data type, but under another name (the template class pair) this data type is defined and used in the C++ Standard Template Library, although you need not know anything about the Standard Template Library to do this exercise. Write a definition of a class named Point that might be used to store and manipulate the location of a point in the plane. You will need to code, declare, and implement the following member functions: a. A member function set that sets the private data after an object of this class is created. b. A member function to move the point by an amount along the vertical and horizontal directions specified by the first and second arguments. c. A member function to rotate the point by 90 degrees clockwise around the origin. d. Two const inspector functions to retrieve the current coordinates of the point. Document these functions with appropriate comments. Embed your class in a test program that behaves as described below. Your program should maintain 3 Point objects that can be modified. You can use an array of point objects (preferred) or you can declare three individual Point objects The program should present a menu with the following options. It should accept both upper and lower case letters for the options, and if what is entered is not one of the options it should print That is not a valid option and display the menu again. The options are as follows: s : set the coordinates of point
m: move a point r : rotate a point
q: quit
The behavior for each function is described below: s: Ask the user which point they would like to set (1-3). Then ask the user to enter the x and y coordinates, separated by a space. Set the point and print the point number (1-3) followed by the coordinates. m: ask which Point they would like to move. Print the current Point number and its coordinates. Then ask for the number of units to move in the x and y directions, separated by a space. Print the new coordinates of the point r: ask which Point they would like to rotate. Print the current Point number and its current coordinates. Then print the new coordinates of the point q: exit the program
Your output must match the following:
Choose from the following options:
s: set a Point's coordinates m: move a Point
r: rotate a Point
q: quit e That is not a valid option.
Choose from the following options:
s: set a Point's coordinates m: move a Point
r: rotate a Point
q: quit s Which point would you like to set? (1-3) 4 Please choose a Point between 1 and 3 2 Enter the x and y coordinates, separated by a space: 1 2 Point 2's coordinates are now 1, 2
Choose from the following options:
s: set a Point's coordinates m: move a Point
r: rotate a Point
q: quit m Which point would you like to move? (1-3) 1 Point 1's coordinates are 0,0 Enter the amount you would like to move in the x and y direction, followed by a space -3 4 Point 1's coordinates are now -3, 4
Choose from the following options:
s: set a Point's coordinates m: move a Point
r: rotate a Point
q: quit M Which point would you like to move? (1-3) 2 Point 2's coordinates are 1, 2 Enter the amount you would like to move in the x and y direction, followed by a space -3 4 Point 2's coordinates are now -2, 6
Choose from the following options:
s: set a Point's coordinates m: move a Point
r: rotate a Point
q: quit r Which point would you like to rotate? (1-3) 2 Point 2's coordinates are -2, 6 Point 2's coordinates are now 6, 2
Choose from the following options:
s: set a Point's coordinates m: move a Point
r: rotate a Point
q: quit Q
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started