This is the exact pseudocode my professor gave. Yes. This is an assignment. I would like advice to help me understand what I could be doing wrong and correct it. I'm sure my indentations and casing are correct. Here's more information about the assignment and some other information she posted in an announcement about it:
Assignment description:
The second part of the Mad Lib project (the first part being the design document due earlier) is to write the code necessary read the Mad Lib from a file and prompt the user:
Please enter the filename of the Mad Lib: madlibZoo.txt
Plural noun: boys
Plural noun: girls
Type of liquid: lemonade
Adjective: fuzzy
Funny noise: squeak
Another funny noise: snort
Adjective: hungry
Animal: mouse
Another animal: blue-fin tuna
Note that there is a tab before each of the questions (ex: "Plural noun:")
Hints
Your program will not need to be able to handle files of unlimited length. The file should have the following properties (though you will need to do error-checking to make sure):
• There are no more than 1024 characters total in the input file.
• There are no more than 32 lines in the input file.
• Each line in the input file has no more than 80 characters in it.
• There are no more than 256 words in the input file including prompts.
• Each word in the input file is no more than 32 characters in length.
Hint: To see how to declare and pass an array of strings, please see Chapter 3.0 of the text.
Assignment
Perhaps the easiest way to do this is in a four-step process:
1. Create the framework for the program using stub functions based on the structure chart from your design document.
2. Write each function. Test them individually before "hooking them up" to the rest of the program. You are not allowed to use the String Class for this problem; only c-strings!
3. Verify your solution with testBed:
testBed cs124/project09 project09.cpp
4. Submit it with "Project 09, Mad Lib" in the program header.
Announcement:
Remember that the string class is not allowed on this project. That is, all text must be stored in c-strings or arrays of characters. For example, you would be docked if you used the first example on the project:
string text = "This variable is not allowed on the madlib project.";
char text[256] = "This is how you should store text in the madlib project.";
Here are some hints for the project:
• As always, use the rubric as your guide.
• You can find a working example of the project at /home/cs124/projects/proj10.out. There are five example files found in that same directory called madLib*.txt. Use this example to help you determine the output and interaction of your program. Here is a screencast of how to run the proj10.out file:
http://www.screencast.com/t/KH0ALYeDM2az
• "Example 3.0 -Array of Strings" gives a great example of how to declare, fill, and display an array of strings. Many students find referring to this example helpful when working on the project.
• To have functional cohesion in your program, a function should do one thing, and one thing only. This doesn't mean it should be one line, but rather, it should be accomplishing one conceptual piece of work.
Error Checking
On page 298 of the textbook it describes the file format and states that you will need to do error checking to make sure the file conforms to this format. Only requirements that affect data storage need to be verified. Here is the list and the important errors to check for:
• There are no more than 1024 characters total in the file. (Do not need to verify)
• There are no more than 32 lines in the file. (Do not need to verify)
• Each line has no more than 80 characters in it. (Do not need to verify)
• There are no more than 256 words in the file. (Needs to be verified)
• Each word is no more than 32 characters in length. (Needs to be verified)
Helpful functions
Some functions that you may find useful for the project are strlen(), isalpha(), ispunct(), tolower(), and toupper(). To use these you will need to include <cctype> and <cstring>.