I'm not THAT good am I?

This is a discussion on I'm not THAT good am I? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Apperantly my noob exploints have reached the seven seas and people have requested that I be their retainer. This is ...

  1. #1
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901

    I'm not THAT good am I?

    Apperantly my noob exploints have reached the seven seas and people have requested that I be their retainer.

    This is a PM I got from Mr. Jon B. ZeroPosts.

    Write a program based on the word game Madlibs. The input to Madlibs is a brief story, with words left out. Players are asked to fill in missing words by prompting for adjectives , nouns, verbs, and so on. When these words are used to replace the missing words, the resulting story is often funny when read aloud.

    In the computerized version of the game, the input will be a text file (called madlib_story.txt) with certain words annotated by enclosing the words in brackets. These enclosed words (i.e., the square bracketed terms, like "[noun]") will be replaced by scanning a dictionary file (madlib_dictionary.txt) for the appropriate word, and placed in an output file (madlib_output.txt) that contains all the unbracketed words in their original positions and the replacement words in the same positions as their corresponding bracketed words' locations. An output line (sentence) should be no more than 60 characters long. You must placed the maximum number of characters on a line. Read your dictionary entries into a vector called "DB." Use "DB" to determine if a bracketed word is a valid dictionary entry (hint: search DB). Your program will simultaneously handle two input files (madlib_story.txt and madlib_dictionary.txt) and one output file (madlib_output.txt). You should handle both input files with the ifstream class, we discussed in class, and the output file with the standard ofstream class. Code your program in a single file, madlibs.cpp. Keep the size of your main function to a minimum.

    The Dictionary File
    The dictionary file will consist of pairs of words (in the madlib_dictionary.txt each pair appears on a separate line). For example, a portion of the dictionary file might be:

    noun cat
    adjective happy
    car-brand mazda
    The first word of each pair is the key, and the second is the value. Together, a pair is called an entry. The only entries in your dictionary are the ones specified by the sample dictionary file. Also make sure you check to see that a bracketed word is a valid dictionary entry. Otherwise you will exhaust you dictionary file on an invalid entry. Example: You should not search your dictionary for a bracketed word like [xxxxx]. [xxxxx] will be printed to your story file.

    The Story File
    This file will consist of text, where some words have a left and right bracket as their first and last characters respectively, e.g.: "[noun]", "[car-brand]". The words in brackets may be followed by a single punctuation mark like a comma, period, or question mark. See the madlib_story.txt for an example.

    The Output File
    Your program should scan through the story file, outputting non bracketed words directly to the output file. For each each "VALID" bracketed word, continue scanning through the dictionary file until reaching an entry with a matching key and send the corresponding value to the output file in place of the "VALID" bracketed word. Thus, the output file should be a copy of the story file, but with the "VALID" bracketed words replaced with terms from the dictionary file.

    Note that using the ifstream object, you will not be able to tell how long the lines of input are. Lines in the output file should be no more than 60 characters long.

    Running your program on the dictionary above and the story file:

    I once owned a [noun] who was [adjective]
    only when in a [car-brand] automobile.
    Should result in an output file (though the line break positions may differ):

    I once owned a cat who was happy only when in a mazda automobile.
    Boundary Conditions
    The next entry in the dictionary may not correspond to the next bracketed word in the story. Your program should skip over dictionary entries until it gets to the next one that matches.
    If the dictionary is exhausted (end-of-file) before the last bracketed word in the story is replaced, your program should merely output the remaining bracketed words as is. An example is shown in the madlib_output.txt
    A bracketed word is strictly defined as one whose first character is a '[' and whose last character is a ']', with no whitespace between. It may be followed by a single punctuation mark. If a word ends with two brackets, treat the second one as the boundary, not as punctuation. To tell whether a character is a punctuation mark, use the function ispunct(ch) defined in ctype.h.
    Any deviation from these conditions will be penalized. (har har)

    The madlib_output.txt shows what might result from running your program on the madlib_story.txt and madlib_dictionary.txt files.

    User Interface
    Your program should require exactly three words of input from the user to run correctly. When I test your project I will use I/O redirection to provide that input to your program.

    Submitting in your project
    You are to submit your code file for the program, madlibs.cpp to blackboard before the due date and time.

    Hints
    You should use two ifstream objects, one to read across the story and the other to read across dictionary, and you will use an ofstream object to create the output file.
    I'm actually flattered.

  2. #2
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    So is he from duke or colgate?
    http://www.google.ca/search?hs=Jiu&h...G=Search&meta=

    well the duke website is from 1997, I think his assignment is late

  3. #3
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    Welll, I doubt you'd find out what his identity was, at most the professor would change the assignment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In a game Engine...
    By Shamino in forum Game Programming
    Replies: 28
    Last Post: 02-19-2006, 11:30 AM
  2. Good books for learning WIN32 API
    By Junior89 in forum Windows Programming
    Replies: 6
    Last Post: 01-05-2006, 05:38 PM
  3. Good resources for maths and electronics
    By nickname_changed in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 12-22-2004, 04:23 PM
  4. what is good for gaphics in dos
    By datainjector in forum Game Programming
    Replies: 2
    Last Post: 07-15-2002, 04:48 PM
  5. i need links to good windows tuts...
    By Jackmar in forum Windows Programming
    Replies: 3
    Last Post: 05-19-2002, 12:16 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21