FMI Table
| Kamen Mladenov | FMI Computer Science Year 1 Group 6 | Project 2 | Project Topic 7 |
Public Member Functions | List of all members
Menu Class Reference

Handles navigation between multiple commands. More...

#include <Menu.h>

Public Member Functions

 Menu ()
 Sets name as "Menu", leaves all flags to false and creates an empty Command list.
 
 Menu (const Command *commands, unsigned commandCount)
 Copies commands.
 
void addCommand (const Command &command)
 Adds a command to the internal Command list.
 
void navigate () const
 Lists commands and after user input executes an appropriate command run() function. More...
 

Detailed Description

Handles navigation between multiple commands.

Shows the title, then below it an Error/Warning/Success message if set, lists all command options as an enumerated list, takes command index and calls the chosen command's run() function.

Member Function Documentation

◆ navigate()

void Menu::navigate ( ) const

Lists commands and after user input executes an appropriate command run() function.

Prints the title, then an Error/Warning/Sucess message (if set), prints all command names as an ordered list (starting from 1), waits for user input to select one of those commands (by list number) and finally executes the appropriate command's run() function.

After the run() function exists, everything is reprinted. The 0 list index is always "Go Back"/"Exit" and it always stops the reprinting loop.

If there are no commands, prints "Menu is empty!". If user input doesn't correspond to any command, registers an error message and reprints.


The documentation for this class was generated from the following files: