DEPARTMENT OF COMPUTING

CS 3005: Programming in C++

Menu System

Introduction

We want to have a text based menu system that allows the user to execute commands from a list of commands. Each command will manipulate the data stored in the program.

Assignment

In this assignment, you will add to the ApplicationData class, and create some new classes that support a menu system. You will also build a very simple program to test this menu system.

The commands this program will have are listed in this table.

Command Prefixable? Function Description
help no menuUI Display help message.
menu no menuUI Display help message.
# yes commentUI Skip to end of line (comment).
comment no commentUI Skip to end of line (comment).
echo no echoUI Echo back the arguments given.
quit no quitUI Terminate the program.

Example Session

$ ./program-menu-test/menu_test 
Choice? # this is a comment, it does nothing.
Choice? #this is a comment, where the command name is a prefix of the command typed.
Choice? comment this is a comment using the command name, not #
Choice? commentthis is a bad comment, because the "comment" command can not be a prefix.
Unknown action 'commentthis'. Use 'help' for a list of valid actions
Choice? echo Hello world!
 Hello world!
Choice? echo "Hello world!"
 "Hello world!"
Choice? echo copies everything after the echo command to the output.
 copies everything after the echo command to the output.
Choice? echo help will show the list of available commands
 help will show the list of available commands
Choice? help
Options are:
  # - Skip to end of line (comment).
  comment - Skip to end of line (comment).
  echo - Echo back the arguments given.
  help - Display help message.
  menu - Display help message.
  quit - Terminate the program.

Choice? echo menu does too
 menu does too
Choice? menu
Options are:
  # - Skip to end of line (comment).
  comment - Skip to end of line (comment).
  echo - Echo back the arguments given.
  help - Display help message.
  menu - Display help message.
  quit - Terminate the program.

Choice? quit

Programming Requirements

Create library-application/ActionFunctionData.{h,cpp}

ActionFunctionData Class

This class represents one command, or action, that the user can execute. Think of it as a row in the table of commands listed above.

public Typedefs:

Data Members:

The following data members should be private or protected. public data members are not allowed.

public Methods:

Update library-application/Makefile

Add ActionFunctionData.{h,cpp} in the appropriate places to add them to the library and install the header file.

Create library-application/MenuData.{h,cpp}

MenuData Class

This class represents all of the commands the user can execute. Think of it as all of the rows in the table of commands listed above.

Data Members:

The following data members should be private or protected. public data members are not allowed.

protected Methods:

These methods must be protected, not public, and not private.

public Methods:

Update library-application/Makefile

Add MenuData.{h,cpp} in the appropriate places to add them to the library and install the header file.

Update library-application/ApplicationData.{h,cpp}

We will update the ApplicationData class to support a text menu based application.

ApplicationData Class

Data Members:

These additional data members should be in the private or protected section of the class. No public data members are allowed.

public Methods:

Create library-commands/menu_test_aux.{h,cpp}

Functions:

Update library-commands/Makefile

Add menu_test_aux.{h,cpp} in the appropriate places to add them to the library and install the header file.

Create program-menu-test/menu_test.cpp

Functions:

Create program-menu-test/Makefile

This file must contain rules such that any of the following commands will build the menu_test program:

Create program-menu-test/.gitignore

The file needs to store one line of text:

menu_test

This will prevent the executable program from being committed to the repository. It is a derived file.

Update Makefile

Additional Documentation

TBA

Grading Instructions

To receive credit for this assignment:

Extra Challenges (Not Required)

TBA

Last Updated 12/01/2024