Program 5, Grandmother's Trunk, Again.
Short Description:
Write a program which will play Grandmother's Trunk.
This assignment is worth 25 points.
Goals
When you finish this homework, you should:
- Implemented and used functions.
Formal Description
Redo program 1, with the following changes.
- Correctly identify the article to use with the phrases.
- Generate random items to include in the computer's response.
- Ask the user if they wish to continue playing the game.
You should create functions to match the following function prototype
- string CorrectArticle(string phrase)
- This function takes a phrase and returns
- The string "an" if the phrase starts with a lower case vowel
- the string "a" for other lower case letters
- The string "The" for phrases that start with an upper case letter.
- This is not completely right, but it will do for now.
- string GetPhrase(void)
- This function takes no parameters and returns the user's input.
- bool Continue(void)
- Asks the user if they wish to continue
- Return true if they say yes (in any form)
- Return false if they say no (in any form)
- string UpperCase(string)
- Takes the input string and converts it to upper case.
- string RandomItem(void)
- Like the magic 8 ball code, selects randomly from a set of items.
You program should look like:
int turn;
bool flag;
string phrase,
article,
story;
....
turn = 0;
flag = Continue();
while (flag) {
if (turn %2 == 0) {
item = GetPhrase();
} else {
item = RandomItem();
}
turn++;
article = CorrectArticle(item);
story = story + "\n and " + article + " " + item;
cout << story << PUNCTUATION << endl;
flag = Continue();
}
...
You should use UpperCase as part of Continue.
Discussion
You should make appropriate use of constants and variables.
Your identifiers should be constructed properly, with meaningful names.
You should document your code with comments.
Your program should be fully interactive and provide the user with instructions.
Your output should be organized, easy to read, and make appropriate use of white space.
You should used the functions outlined above.
Required Files
A single source code file.
Submission
Email your final source code file to danbennett360@gmail.com.