Advanced Bash - Assignment 2

Created Friday 23 February 2018

This assignment will give you some practice with both "bash scripting" and dealing with translating ideas to code. Remember your basics: be sure to "chmod +x" your file before trying to run it, also be sure to save multiple versions of your code, especially as you move from one phase to the next.

And now: Probably the shortest set of instructions for an assignment I can give:

Implement Mad Libs.

(if you're perhaps unfamiliar — )

The story is up to you, and this will be a bit of a "rolling" assignment. You should *certainly* be able to do phase 1 right now, probably phase 2 as well. The rest may require a bit more from me next week. Either way I'd like to see how far everyone gets regardless; please feel free to ask questions and to give me feedback generally. I will perhaps add more information as time goes on, but I think the hints should get us where we need to go. The only time you'll need to turn in the whole thing is when you've completed all 5 phases, which will not be at least until Spring Break begins.

I've deliberately worded these a bit vaguely, in order to let you try to think about how to accomplish each task. I've provided "further hints," but for each phase, brainstorm a bit on how you might do it — and please let me know if you come up with something different or interesting; it's one of the best things that happens in this course.

Phase 1:

The user will be prompted for a series of words identified by parts of speech (at least 4). Upon completion, the script will print back the story to the screen. The story is up to you!

Phase 2:

These may just end up being masterpieces. So, maybe we'd like to save them; for this we'll need unique names. Before we get to the words, we will ask for a name. Upon completion we will BOTH print the story to the screen AND save the the story with the format $usernames-story.txt — i.e. my story would be saved as johnsstory.txt

Phase 3:

Because these things can get a little naughty, we're going to prevent underage users from using the program, using the same extremely accurate and defensive system used by gaming and porn websites across the world; we're just going to ask and assume they're not lying. So, before the user is prompted for nouns and verbs et. al., we're going to ask for their age; the program should only proceed if the user is 18 or older. (Feel free to keep a list of logins?)

Phase 4:

In which we remember that people are lazy. Revisit your phase 1 code, but let's forget the whole prompting thing. Instead, give your code the ability to generate randomly different stories (i.e. with different parts-of-speech words every time it's run). Obviously, you'll have to figure out a way to get random words, of the correct type, no less....

Phase 5:

Dominate the world with a bot-led army of A.I. storytellers. Specifically — Prompt the user for a number, and then generate and save that many stories, with attribution to random peoples names, e.g. janesstory.txt, joesstory.txt.


Backlinks: FSU Courses:LIS5364