1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152

//Write a program that includes a definition for a class named Point that stores and manipulates the location of a point on a plane [integers only]. You will need to declare and implement the following member functions:
//i) A member function set that sets the private data after an object of this class is created
//ii) A member function to move the point by an amount along the vertical and horizontal directions as specified by the first and second arguments
//iii) A member function to mirror the point on either the x or y axis or both by using one or more parameters to determine which of these three options to apply
//iv) Two functions to retrieve the current coordinates of the point
//Your program will prompt a user for a set of points, first asking how many points
//will be in the set, then reading in the points. The program then offers the user the following menu until the user exits:
//A) enter a new set of points [will restart from the begining]
//B) move a particular point along the x axis, y axis, or x and y axis
//C) mirror a particular point along the x axis, y axis, or x and y axis
//D) output all of the points in their current state
//E) exit
//ALGORITHM: you must include an algorithm at the top of your program which is a 'recipe' for how you will approach the problems of the program to make them work properly in code
//COMMENTS: you must include comments in the program to describe variable declarations, methods/functions, loops, and any equations or vital calculations
//GRADING:
//Algorithm 010 points
//Comments 010 points
//Class Usage 030 points
//Meets Requirements in Description 030 points
//Free of Errors based on testing multiple iterations 020 points
//So, I'll be needing:
// A class, Point
// A class member x that holds data pertaining to X
// A class member y that holds data pertaining to Y
// A variable for how far X needs to move (moveX)or do I just replace the point entirely?
// A variable for how far Y needs to move (moveY)
// A function to multiply X, Y, or both by 1 (for mirroring)
// A variable for the number of points to be dealt with (n)
// A variable for the menu selection (menuSel)where you can choose 1 (enter new points), 2 (move point), 3 (mirror point), 4 (output current points), or 5 (exit)
// Note to self, functions go in Public and variables go in Private
#include <iostream>
using namespace std;
class Point //creates a class Point
{
public:
void move (int); //this will be the function to move a point along one or both axis
void mirror (int); //this will be the function to mirror a point along one or both axis
int getX(int); //this is an accessor function to get X values
int getY(int); //this is an accessor function to get Y values
int xOne;
int yOne;
int xTwo;
int yTwo;
private:
int x; //holds data pertaining to X1
int y; //holds data pertaining to Y1
};
int Point::getX()
{
return x;
}
int Point::getY()
{
return y;
}
void move (int x, int y) //creates the definition of the function move, to move a point along one or both axes
{
cout << "Where would you like to move the point to along the x axis? "; //asks user what they would like to change the xcoordinate of the point to
cin >> x; //reads in a new xcoordinate
cout << "Where would you like to move the point to along the y axis? "; //asks user what they would like to change the ycoordinate of the point to
cin >> y; //reads in a new ycoordinate
Point::xOne = x;
Point::yOne = y;
}
void mirror (int x, int y) //creates the definition of the function mirror, to mirror the point across one or both axes.
{
char choice; //initializes a variable to hold the user's choice 'y' or 'n'
cout << "Would you like to mirror the point across the x axis? Y/N "; //asks user if they would like to mirror a point across the x axis
cin >> choice; //reads in user's choice, y or n
switch (choice) //if user inputs Y or y, the point will be mirrored across the xaxis. If the user inputs N or n, the point will not be mirrored. If the user inputs anything else, the point will not be mirrored.
{
case'Y':
case'y':
x * 1;
Point.x = x;
break;
case'N':
case'n':
break;
default:
break;
}
cout << "Would you like to mirror the point across the y axis? Y/N "; //asks the user if they would like to mirror a point across the y axis
cin >> choice; //reads in user's choice, 'y' or 'n'
switch (choice) //if user inputs Y or y, the point will be mirrored across the yaxis. If the user in puts N or n, the point will not be mirrored. If the user inputs anything else, the point will not be mirrored.
{
case'Y':
case'y':
y * 1;
Point.y = y;
break;
case'N':
case'n':
break;
default:
break;
}
}
int main ()
{
int n; //number of points
int menuSel;
cout << "Enter the number (between 1 and 10) of points you wish to input: "; //prompts user to input the number of points they wish to enter
cin >> n; //reads in the number from the user
for (int i = 0; i < n; i++) //this loop should allow you to enter n points
{
cout << "\n Enter a point's X coordinate. "; //prompts user to input the x coordinate of a point
cin >> Point::x1; //reads data into an array of X values
cout << "\n Enter a point's Y coordinate. "; //prompts user to input the y coordinate of a point
cin >> ; //reads data into an array of Y values
}
cout << "Please choose an action from the selections below:" << endl << "1. Enter a new set of points" << endl << "2. Move a particular point along the Xaxis, Yaxis, or both." << endl << "3. Mirror a particular point around the Xaxis, Yaxis, or both." << endl << "4. Output all points at their current location." << endl << "Exit the program.";
cin >> menuSel;
switch (menuSel)
{
case 1:
return 1;
break;
case 2:
//CODE FOR MOVING POINTS
break;
case 3:
//CODE FOR MIRRORING POINTS
case 4:
cout << "(" << Point::xOne << ", " << Point::yOne << ")";
case 5:
return 0;
default:
cout << "Invalid menu selection! Exiting program.";
exit (1);
}
