Assignment 08

Also, the answers you generate and output can be rather long. You don't need to worry about losing points for "wrap-around" in the output (going past the 80th column).

The Data: The data for the files is extensive. For you to type in all the answers and nouns to create the files would be odious (oooooh, I like that word). Thus, we are providing those files for you and a very simple way to "download" them. Create the directory where you are going to make your hw8 program, and then change to that directory. Then, at the unix prompt, type

  • wget http://web.mst.edu/~price/1570/moe_rals.txt

  • wget http://web.mst.edu/~price/1570/moe_rants.txt

  • wget http://web.mst.edu/~price/1570/fable1.txt

  • wget http://web.mst.edu/~price/1570/fable2.txt

  • wget http://web.mst.edu/~price/1570/fable3.txt

  • wget http://web.mst.edu/~price/1570/fable4.txt

  • wget http://web.mst.edu/~price/1570/fable5.txt

  • wget http://web.mst.edu/~price/1570/list1.txt

  • wget http://web.mst.edu/~price/1570/list2.txt

Doing this will copy the files from my directory into yours named moe_rals.txt, moe_rants.txt, etc. You'll see them when you issue the unix command ls. This will save you a LOT of time. IF you wish to add other words/phrases to the lists, feel free to do so. However,

  • keep it CLEAN (don't be childish....like us)

  • use a pure-text editor like jpico or notepad or nano. If you use other editors, you may introduce hidden or naughty control characters that we accept NO responsibility for. I suggest you leave the files alone until you get your program completely working correctly before you add anything to the data. That way you are certain that any ensuing issues are from your modifications of the files and not your code. Also, think about capitalization!

You may assume the following about the data files:

  1. each fable will have a newline character at the end of the fable

  2. there is a single space between any two "words" in all files. This means a single space between words and between sentences.

  3. there is a newline at the end of each line in the list files and the rants and rals files.

Warning: This assignment is NOT trivial. It will take time and careful coding. Don't underestimate it. As an example of unforeseen issues you will have with this assignment, some words that will need to be replaced might also have attached punctuation that should be transferred to the replacement word. This takes special attention and isn't trivial.

When you submit: Create two Moe fables and then quit.

And as always, don't hesitate to ask if you have questions.

Special Note: You are to use only null-terminated character arrays (NTCAs) for the coding in this assignment. You can use the standard string only for file names if you need/want. Think carefully how your code will read and handle the data. Remember that you have been taught how to read in char-by-char, word-by-word, and line-by-line. Also, you are allowed to work in a group of no more than two people if you want. (This is only true for this assignment.) A group of two is optimal and can make an optimal coding team. We encourage that. Your partner must have the same cs 1570 instructor. Put both names on every file for this program. Submit under ONLY ONE NAME so that we print only one copy. Groups of one person is ok. Groups of 0 are strictly forbidden as this tends to suggest sympathetic Zombie behavior forbidden by Missouri's anti-zombie laws. We're a little backwards in this state! Not like, say, California.

And the output is to be to a output file called MoeFables.txt. And be sure to output a couple of blank line between fables and a blank line between the fable and its Moe-rale.

The Moe-rale of this story is: blah blah blah so forth and so on...

....and the drunk ate the barstool and ran away.

Specifications: Your program is to prompt Moe "So, Moe, are you ready to create a fable?" with the expectation of an affirmative or negative response. After the first fable is done, re-prompt him for doing another. A negative response in either case will terminate the program. When a fable is wanted, your program will read from a file, that is chosen at random, one of Aesop's fables. The first sentence of the fable will be the title of that particular fable. It will always be of the form "The something and the somethingelse fable". Then the following sentences are the fable about something and somethingelse. You first must "capture" what the something and somethingelse are from that first sentence. Then, in the following sentences, replace every instance of something and somethingelse with a replacement word. The replacement words will be chosen at random (once per fable) from two other files; something is replaced by a word from the first of these two files, and somethingelse is replaced by a word from the second of the two files. For example, let's suppose that the Aesop fable chosen starts as The stag and the crow fable. Your code will then recognize "stag" and "crow" as the words to replace; stag replaced by a word from one file, and crow replaced by a word from another file. Suppose then that your code at random chose "Homer" to replace stag and "beer bottle" to replace crow. In the ensuing fable, every instance of stag is replace by Homer, and every instance of crow is replaced by beer bottle. Furthermore, any word in the fable that follows either word "a" or "the" must be replaced by some other word drawn at random from the second file (unless it is the something or somethingelse words). At the end of the fable, Moe wants your program to state a morale of the story. Since Moe, deep thinker that he is, has written down several of these gems over the years in his Big Chief notebook (with a blue crayon), they will be supplied to you in another file. Your code is to pick at random a "Moe-rale" from this file to append to the end of his Moe fable. And, to top it all off, at the end of every sentence in the fable, there is a 1 in 4 chance that you will insert into the fable at that point one of Moe's rants, of course chosen at random. A file of these is also given.

Output the original fable first. Then, output the modified one, with a blank line or two between them...maybe even a nifty label saying which is which....though it should be obvious.

Your modified fable output should look something like this:

Moe Fable #1: The drunk and the barstool fable. Once upon a time, in a bar far, far away .....

Due: Monday, April 15, 2019 at Noon 100 points

Instructions: For this assignment, you will submit multiple files containing a program written in C++. You know the rest. However, see Special Note below, subsection Also for special submission instructions.

Background: Moe, he's slightly smarter than your typical moron, but that's what makes him endearing and so interesting to us. But I digress. Moe really wants to shed his image of being an idiot, so he's going to try to engage in literary genius, wow his customers with his lettered prowess, galvanize patrons with erudition, pique their interest with his mastery of the spoken word and thought. So, he's going to steal Aesop's fables, butcher them with barroom profundity, and rename them "Moe's Fables". But, of course, he's also lazy and so he wants you to write a program that will do it for him. Thus, you will have to imagine that the program you write will be used by Moe himself as he creates fables to post around the bar in hopes of impressing visitors and friends alike.