// Filename: SHELL.CPP
// Purpose:  Acts as a general purpose "shell" program, i.e., often a
//           good starting point when you begin to code a new program.

#include <iostream>
#include <iomanip>
// Enter additional required header file(s) starting on this line

void DisplayIDInfo(int);
void DescribeProgram();
void DisplayMainMenu(int);
void GetMenuChoice(int, int&);
void Pause(int);
// Enter additional required function prototype(s) starting on this line


int main()
{
    const int INDENT_LEVEL = 19;
    int menuChoice;

    DisplayIDInfo(INDENT_LEVEL);

    do
    {
        DisplayMainMenu(INDENT_LEVEL);
        GetMenuChoice(INDENT_LEVEL, menuChoice);
        switch (menuChoice)
        {
            case 1:
                cout << endl;
                break;
            case 2:
                DescribeProgram();
                break;
            case 3:
                cout << endl
                     << "Now performing some action ... "
                     << "(not really--it *is* just a demo) ... "
                     << endl;
                break;
        }
        if (menuChoice != 1)
            Pause(0);
    } while (menuChoice != 1);
    cout << endl;

    return 0;
}

void DisplayIDInfo(int indentLevel)
// Pre:  indentLevel contains a nonnegative integer.
// Post: Programmer's identification information has been displayed,
//       preceded and followed by a blank line.
{
    cout << endl;
    cout << setw(indentLevel) << ""
         << "LASTNAME, Firstname " << endl;
    cout << setw(indentLevel) << ""
         << "Add other ID lines starting here ... " << endl;
    cout << endl;
}


void DescribeProgram()
// Pre:  none
// Post: A program description has been displayed,
//       preceded and followed by a blank line.
{
    cout << endl;
    cout << "This program is just a demo ... " << endl;
    cout << endl;
}


void DisplayMainMenu(int indentLevel)
// Pre:  indentLevel contains a nonnegative integer.
// Post: A menu has been displayed, each line indented indentLevel spaces.
//       The menu is preceded and followed by two blank lines.
{
    cout << endl << endl;
    cout << setw(indentLevel) << "" << "Main Menu ";
    cout << endl << endl;
    cout << setw(indentLevel) << "" << "1. Quit "                << endl;
    cout << setw(indentLevel) << "" << "2. Get information "     << endl;
    cout << setw(indentLevel) << "" << "3. Perform some action " << endl;
    cout << endl << endl;
}


void GetMenuChoice(int indentLevel, int& menuChoice)
// Pre:  indentLevel contains a nonnegative integer.
// Post: A prompt has been displayed, indented indentLevel spaces,
//       and menuChoice contains an integer entered by the user.
{
    cout << setw(indentLevel) << "" << "Enter your choice here: ";
    cin >> menuChoice;  cin.ignore(80, '\n');
    cout << endl;
}


void Pause(int indentLevel)
// Pre:  The standard input stream cin is empty, and indentLevel
//       contains a nonnegative integer.
// Post: A prompt has been displayed, indented indentLevel spaces,
//       and the user has pressed <RETURN>.
{
    char newlineChar;
    cout << setw(indentLevel) << "Press <RETURN> to continue ... ";
    cin.get(newlineChar);
    cout << endl;
}
