// Your program implements some functionality extensively used in graphical user interfaces (GUI) and computer games. The program collects points/coordinates, given by user and stores them in a container.
// Points are represented by the structure Point
// struct Point
// {
// int x;
// int y;
// }
// The program displays a menu with the following items
// Add a new point
// Select points
// Print all points
// Print selected points
// Exit
// The user enters a number to select an item from the menu. Depending on the user’s choice the program does the following:
// Asks the user to enter x-coordinate and y-coordinate of a new point. Adds this new point to the vector of points.
// Asks the user to enter 2 points. These points define a rectangle. Select all the points inside that rectangle. Selecting is done by storing in a separate vector the indexes of selected points in the main container. It is up to you if you want to select the points located right on the borders of the rectangle. Keep in mind that the user can enter any two points to define a rectangle in any order.
// Prints all points on one line in the following format:
// (12,2) (3,4) (-5,0) (39,101)
// Prints only the selected points in the same format as 3.
// Ends the program execution.
// You must use functions extensively. The function main should do only the minimal work like getting user input. All menu options except Exit should be implemented by a separate function. If a function takes point as a parameter, it should take Point, not separate x- and y-coordinates.
// You should NOT use any global variables. Use references to pass vectors to functions. If the function doesn’t change the vector, it should receive that vector as a const reference
Here's what I have so far:
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
|
#include <iostream>
#include <vector>
using namespace std;
short menu_buttons (short menu_num);
short add_point();
short select_points();
short print_all_points();
short print_selected_points();
//Main Menu
int main()
{
cout << "Main fucking Menu\n"
<< " 1. Add Point to list\n"
<< " 2. Select Points\n"
<< " 3. Show all Points\n"
<< " 4. Show selected points\n"
<< " 5. Exit because you're done ruining my July 4.\n"
<< " Enter a number from the menu:";
short menu_num;
cin >> menu_num;
menu_buttons(menu_num);
return 0;
}
//Menu buttons
short menu_buttons(short menu_num)
{
if (menu_num == 1)
{
add_point();
}
else if (menu_num == 2)
{
select_points();
}
else if (menu_num == 3)
{
print_all_points();
}
else if (menu_num == 4)
{
print_selected_points();
}
else if (menu_num == 5)
{
cout << "\nGood-bye! \n";
return 0;
}
else if (menu_num != 1)
{
cout << "\nYou've typed bullshit. Restarting menu:\n";
main();
}
return 0;
}
short add_point()
{
cout << "test";
return 0;
}
short select_points()
{
cout << "test";
return 0;
}
short print_all_points()
{
cout << "test";
return 0;
}
short print_selected_points()
{
cout << "test";
return 0;
}
|