Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

---------------------

Step by Step Solution

3.47 Rating (144 Votes )

There are 3 Steps involved in it

Step: 1

The C program for creating an AdLib ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Probability And Statistics

Authors: William Mendenhall, Robert J. Beaver, Barbara M. Beaver

13th Edition

0495389536, 9780495389538

More Books

Students also viewed these Accounting questions

Question

The major enterprises are GNMA, FNMA, and FHLMC. LO.1

Answered: 1 week ago

Question

8. Name the three catecholamine neurotransmitters.

Answered: 1 week ago