hw8.h
/*
Programmer: Jennifer Leopold
Date: March 14, 2016
File: hw8_functs.cpp
Purpose: This file contains the prototypes of the functions
for the program that generates poetry.
*/
#ifndef H8_H
#define H8_H
using namespace std;
// ***********************************************************
// Constants
// Constraints on the min and max lines a poem can be, and the
// # of words that can be in one line of a poem
const short MAX_LINES = 10;
const short MIN_LINES = 0; // 0 indicates user wants to quit
const short MAX_WORDS_IN_POEM_LINE = 20;
const short MAX_CHARS_IN_POEM_WORD = 80;
// The encodings for different word types, as used in the
// patterns file
const short NOUN = 1;
const short ADJECTIVE = 2;
const short VERB = 3;
const short PRONOUN = 4;
const short ADVERB = 5;
const short INTERJECTION = 6;
const short NUM_WORD_TYPES = 6;
const string END_OF_PATTERN = "-1"; // denotes end of pattern
// The file name for each word type
const string WORD_FILENAMES[] =
{"nouns", "adjectives", "verbs", "pronouns", "adverbs",
"interjections"};
// The file name for the various possible word patterns
const string PATTERN_FILENAME = "patterns.dat";
// Maximum length of a file name (when specified as char array)
const short MAX_LENGTH_FILENAME = 20;
// ***********************************************************
// Function prototypes
// Prompt for and get integer input from the user, making
// sure it is within specified bounds.
// Preconditions: Parameter 'prompt' contains a string
// question the user is entering input for. Parameter
// 'lowerBound' should be less than 'upperBound'.
// Postconditions: Integer is returned that is >= lowerBound
// and <= upperBound.
int getIntInput(const string prompt, const int lowerBound,
const int upperBound);
// Generate a poem that is a specified number of lines long.
// Preconditions: Parameter 'numLines' is between MIN_LINES..
// MAX_LINES (inclusive).
// Postconditions: 'numLines' many lines of poetry have been
// displayed on the screen.
void generatePoem(const short numLines);
// Return a word of the specified type, randomly chosen from
// the appropriate data file.
// Preconditions: Parameter 'wordType' is the value of one of
// the valid word type constants: NOUN, ADJECTIVE, VERB,
// PRONOUN, ADVERB, or INTERJECTION.
// Postconditions: A randomly chosen word of the specified
// type is returned.
string getRandomWordFromFile(const short wordType);
// Return a randomly chosen poem pattern and the number of
// entries (which relates to word types and literal words)
// in that pattern.
// Preconditions: None.
// Postconditions: A randomly chosen poem pattern and the
// number of entries in that pattern are returned through
// the parameters 'poemPattern' and 'numWordsInPattern'.
void getPoemPattern(string poemPattern[],
short &numWordsInPattern);
#endif