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, remember you need to run with the "full path" or equivalent (./script.sh) 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 — https://en.wikipedia.org/wiki/Mad_Libs )
The story is up to you, and this will be a bit of a "rolling" assignment. More details on requirements below, but first;
As of class on Feb 14, we have *technically* covered everything.- but a week later I will review as well as cover what will be needed for Versions 3,4 and 5. Over time, 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 and hints as time goes on.
The only time you'll need to turn in the whole thing is when you've completed all 5 phases.
I've deliberately worded these a bit vaguely, in order to let you try to think about how to accomplish each task. Soon I may provide "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.
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! (echo and read are your biggies here)
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 johns-story.txt*
*it is possible to use spaces and/or apostrophes, but these are going to make things a bit rough with escapes and all, so I'd recommend avoiding that for now
NOTE, The following bits we went over, but only very quickly. I do not mind you discussing the above, but please avoid discussion of the below for now.
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?)
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....
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.
Unlike many academic assignments, I fully expect that you are likely to reuse code from one Version to another* — by default I am expecting five discrete files, one for each Version. That being said, in most scripting and programming there are MANY effective ways of doing something, and if you develop a way that deviates from this number, that is fine — but it must be well documented.
*Note, if you are reusing code extensively WITHIN one Version, i.e. you find yourself copying and pasting at all, you are almost certainly doing something in a less-than-ideal way. While I'm usually a fan of "if it works it works," a good coder identifies ways to reduce that sort of repetition by making the computer to the work. Laziness is a *good* characteristic of a programmer ☺
HOW TO TURN IN
There will be an assignment in Canvas. It will allow updating your work. Please Turn in at least 5 files, one for each version, clearly labelled. A good naming convention might be:
and so on. Again, code reuse is fine, but I do need at least one file per version. If you use other files, include or provide links to them as well. Be sure to consider how you are referencing to or linking to other files if you are using them, especially if I am attemping to run your code on my machine to test it. (e.g. complete paths to local files like '/home/suzie/myfile.txt' — because '/home/suzie/' doesn't exist on my machine. Perhaps use relative links, and to make it easy, just keep everything in one folder.
The easiest way to move everything may just be to zip your files and upload that, through e.g. an Archive Manager or similar. E.g.
For mint - https://itsfoss.com/linux-zip-folder/
For the Pi https://magpi.raspberrypi.com/articles/unzip-and-uncompress-files-on-a-raspberry-pi