Question: Console Menu Class - for C++ You will write a Menu class that can be used to easily implement console menus, and you will demonstrate

Console Menu Class - for C++

You will write a Menu class that can be used to easily implement console menus, and you will demonstrate that your menus work with the main program in thestarter code. Your demonstration will include sub menues. Your menu class should work with the starter codes Source.cpp.You should not change Source.cpp at all(you may make minor changes if you wish to implement Menu in a slighly different way, but please check with me first).

Download the starter code. Do your work in the starter code project, zip it up into a zip archive and upload your work here.

A menu is made up of

  1. The first and last lines of the menu are a line of \"*\"s
  2. A header that says what the menu is about apears at the top of the menu items
  3. A list of menu items each menu item should have
    1. Akey, a single char that the user enters to select that item
    2. Adescription, the key and description are displayed by the menu
    3. Anaction, a function object, function pointer, or lambda, that does the action required for that menu selection
  4. An exit menu item with key Q, you can hard code this.
  5. Your menu should work for upper and lower case letters.

You may use the included data structure to hold the description and action, or you can desing your own.

struct MenuItem {

MenuItem() {}

MenuItem(const std::string& desc, std::function command)()>

: description(desc)

, command(command)

{ }

std::string description;

std::function command;()>

};

YouMUSTuse a map to store and loop up the menu item by key and perform the menu action.

Here's the starter code:

[ #include Menu.h 4 5 6 7 void hangman(); void fizzBuzz(); 8 9 10 11 @int main() { Menu menu( std::\">

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!