QuestionQuestion

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 PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse 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();...
$35.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats