Create a type of story game by implementing a dynamic stack that holds words. Then we will
Question:
Create a type of story game by implementing a dynamic stack that holds words. Then we will use the words to fill in the blanks of a story we have already created. Your story (create your own story) must be at least 2 sentences long and it must have at least 5 blanks. While this is built on the idea of AdLibs (http://www.sundhagen.com/babbooks/adlib.cgi.), we will not be storing the parts of speech with the words. Our game will be more free-flow than that.
**Dynamic stacks is section 19.2 in your textbook, starting on page 1182. You will be creating a linked list to implement this.
Programming Requirements:
Create a looping menu-driven program to demonstrate your code so that the user has the choice of:
1. Push (a word onto the stack)
2. Pop (a word off the stack)
3. Concatenate (the top two words on the stack and replace those two words with the resultant concatenation. (Shorten resultant word if necessary.)
4. Add an "s" (to the end of the top word on the stack)
5. Display Stack
6. Make a Story (Pop words from the stack and use them to fill in the blanks of a story that you have created. Display the story.)
Validation rules:
Two levels of validation are required: high-level in the main (while loop to control user input) and low-level in the mutators which will cause an exit_failure if the strings they receive are not valid.
Push: Words cannot be blank and they cannot be longer than 10 letters.
Pop - validate for stack not being empty.
Concatenate - validate for at least two words on the stack.
Add an S - validate for stack not empty.
Make a Story - validate that there are enough words on the stack to fill in all your blanks. If not then notify user and do not display the story.
Programming Notes:
Make sure main() is properly organized into functions and don't forget to document your code including your class.
An example which shows a few of the operations. For brevity I did not show the menu, but you would offer it each time.
Push cat
Push angst
Push windy
Push sailboat
Push dog
Push fast
Display Stack:
fast
dog
sailboat
windy
angst
cat
Concatenate
Display Stack:
fastdog
sailboat
windy
angst
cat
Push crazy
Display Stack:
crazy
fastdog
sailboat
windy
angst
cat
Make a Story:
So the other day I went a bit CRAZY and decided to drive my FAST DOG down to San Diego. The SAILBOAT was WINDY and in the end my crew loved the ANGST.
Display Stack:
cat
---------------------
Introduction to Probability and Statistics
ISBN: 978-0495389569
13th edition
Authors: William Mendenhall, Robert J. Beaver, Barbara M. Beaver