fables.h

// Programmer: Clayton Price date: 11/1/13

// File: fables.h cs 53

// Purpose: This file contains the function protos and constants used in the

// fable changing program.

#ifndef FABLES_H

#define FABLES_H

#include <iostream>

#include <fstream>

#include <cstring>

#include <ctime>

#include <cstdlib>

using namespace std;

// name of proprietor of business - presumed user of the program.

const string USER = "Moe";

// const size of array to hold a word

const short MAX_WORD_SIZE = 40;

// const size of array to hold a line of text

const short MAX_LINE_SIZE = 500;

// number of files holding fables

const short NUM_FABLES = 5;

// the probability the USER rants at the end of a sentence.

const short PROB_RANT = 25;

// this array contains the names of the fable files that will be indexed into.

const string FABLE[NUM_FABLES] = {

"fable1.txt",

"fable2.txt",

"fable3.txt",

"fable4.txt",

"fable5.txt"};

// The file_length() function will return the length of the file(number of lines)

// whose file name is passed.

// Pre: parameter must be null terminated.

// post: number of lines in text file returned.

short file_length(const char filename[]);

// The get_random_word() function will change the first parameter (ref) to be a

// line (word) chosen at random from the file whose name is passed and whose

// size is the last parameter.

// Pre: filename must be null-terminated and size must be the number of lines

// in the file.

// Post: word is given a random value from the file passed.

void get_random_word(char word[],const char filename[],const short size);

// The get_random_fable_file() function will return the name of one of the fable

// files at random from the array of file names listed above.

// Pre: none

// Post: name of a file is returned.

string get_random_fable_file();

// The get_title_nouns() function will return via ref parameters the nouns found

// in the first line of the fable contained in the file whose name is the

// last parameter.

// Pre: file must one of the fable file names listed above.

// Post: word1 and word2 will be null terminated arrays containing the nouns in

// the first line of the fable whose name is the parameter file.

void get_title_nouns(char word1[],char word2[],const string file);

// The process_fable() function will replace noun1 and noun2 with replacemant1

// and replacement2, replace other words following pronouns "a" and "the"

// with randomly chosen words from list2, randomly insert lines from rantfile

// and randomly append a line from moerals at the end of the fable.

// Pre: char arrays must be null terminated, fable_file must contain only text,

// lst three parameters are the lengths of the files so designated.

// Post: replace noun1 and noun2 with replacemant1

// and replacement2, replace other words following pronouns "a" and "the"

// with randomly chosen words from list2, randomly insert lines from rantfile

// and randomly append a line from moerals at the end of the fable.

void process_fable(const char noun1[],const char noun2[],

const char replacement1[],const char replacement2[],

const string fable_file,const short list2_length,

const short rantfile_length,const short moerals_length);

#endif