Menu: Difference between revisions
Content added Content deleted
m (→{{header|C++}}: formatting) |
m (neaten up heading material) |
||
Line 4: | Line 4: | ||
* Print a textual menu formatted as an index value followed by its corresponding string for each item in the list. |
* Print a textual menu formatted as an index value followed by its corresponding string for each item in the list. |
||
* Prompt the user to enter a number. |
* Prompt the user to enter a number. |
||
* |
* Return the string corresponding to the index number. |
||
The function should reject input that is not an integer or is an out of range integer index by recreating the whole menu before asking again for a number. The function should return an empty string if called with an empty list. |
The function should reject input that is not an integer or is an out of range integer index by recreating the whole menu before asking again for a number. The function should return an empty string if called with an empty list. |
||
For test purposes use the four phrases: |
For test purposes use the four phrases: “<tt>fee fie</tt>”, “<tt>huff and puff</tt>”, “<tt>mirror mirror</tt>” and “<tt>tick tock</tt>” in a list. |
||
Note: This task is fashioned after the action of the [http://www.softpanorama.org/Scripting/Shellorama/Control_structures/select_statements.shtml Bash select statement]. |
Note: This task is fashioned after the action of the [http://www.softpanorama.org/Scripting/Shellorama/Control_structures/select_statements.shtml Bash select statement]. |