Question
Write a main.cpp to include the structs and enums:
1.1. enum MenuOptions
1.1.1. INIT, NEW_GAME, PRINT_MAP, BUILD, EXIT_PROGRAM
1.2. structs. You may include a Coordinate struct in the code to help with some of the functionality, but it is not required.
2. Add the new functionality for the menu system to main.cpp, using the menu processing loop
2.1. create_new_game( Map & map ): Change the size of the map, and update the map’s items correctly (it’s a pointer!!). (See sample output for format.)
2.2. print_map( Map & map ): Display each of the MapItems in the map’s items list. (See sample output for format.)
2.3. build( Map & map ): Prompt the user for x and y coordinates, and a “building code” (for now, just a single character), and update the correct item.

Tips
1. Note that the size field in our Map struct is for one side of our map - you need to do some math to create a size by size array dynamically in items.
2. We’re working with pointers! Remember that any time you use new, you must eventually use delete to free the memory!

Sample Output
User input is italicized, in bold.
➜./driver
1. New Game
2. Print Map
3. Build Something
4. Exit
Enter your selection: 2

1. New Game
2. Print Map
3. Build Something
4. Exit
Enter your selection: 1

What size map would you like? 10
1. New Game
2. Print Map
3. Build Something
4. Exit
Enter your selection: 2

E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E

1. New Game
2. Print Map
3. Build Something
4. Exit
Enter your selection: 3

Enter x and y coordinate: 1 1
Enter a building code: R

1. New Game
2. Print Map
3. Build Something
4. Exit
Enter your selection: 2

E E E E E E E E E E
E R E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E

1. New Game
2. Print Map
3. Build Something
4. Exit
Enter your selection: 3

Enter x and y coordinate: 1 0
Enter a building code: F
1. New Game
2. Print Map
3. Build Something
4. Exit
Enter your selection: 2

E F E E E E E E E E
E R E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E

1. New Game
2. Print Map
3. Build Something
4. Exit

Enter your selection: 4

➜ ./driver
1. New Game
2. Print Map
3. Build Something
4. Exit

Enter your selection: 1
What size map would you like? 5
1. New Game
2. Print Map
3. Build Something
4. Exit

Enter your selection: 2
E E E E E
E E E E E
E E E E E
E E E E E
E E E E E
1. New Game
2. Print Map
3. Build Something
4. Exit

Enter your selection: 3
Enter x and y coordinate: 0 0
Enter a building code: R
2. Print Map
3. Build Something
4. Exit

Enter your selection: 2
R E E E E
E E E E E
E E E E E
E E E E E
E E E E E
2. Print Map
3. Build Something
4. Exit

Enter your selection: 1
What size map would you like? 10
1. New Game
2. Print Map
3. Build Something
4. Exit

Enter your selection: 2
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
E E E E E E E E E E
1. New Game
2. Print Map
3. Build Something
4. Exit

Enter your selection: 4
Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references.
Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.

#include <cstdlib>
#include <iostream>
using namespace std;

enum MenuOption {
    INIT = 0, // initialize value of the first option
    NEW_GAME, // = 1
    PRINT_MAP, // = 2   
    BUILD, // = 3
    EXIT_PROGRAM // = 4
};

struct MapItam{
    char type;
};

struct Map{
    int size;
    MapItam * items;
};

void create_new_game( Map & map );
void print_map( Map & map );
void build( Map & map );
void printMenu();
This is only a preview of the solution.
Please use the purchase button to see the entire solution.
By purchasing this solution you'll be able to access the following files:
Solution.cpp
Purchase Solution
$35.00
Google Pay
Amazon
Paypal
Mastercard
Visacard
Discover
Amex
View Available Computer Science Tutors 645 tutors matched
Ionut
(ionut)
Master of Computer Science
Hi! MSc Applied Informatics & Computer Science Engineer. Practical experience in many CS & IT branches.Research work & homework
5/5 (6,806+ sessions)
1 hour avg response
$15-$50 hourly rate
Pranay
(math1983)
Doctor of Philosophy (PhD)
Ph.D. in mathematics and working as an Assistant Professor in University. I can provide help in mathematics, statistics and allied areas.
4.6/5 (6,696+ sessions)
1 hour avg response
$40-$50 hourly rate
Leo
(Leo)
Doctor of Philosophy (PhD)
Hi! I have been a professor in New York and taught in a math department and in an applied math department.
4.9/5 (6,467+ sessions)
2 hours avg response

Similar Homework Solutions