1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
#include "moefables_function.h"
#include <iostream>
#include <fstream>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <string>
using namespace std;
void Greeting()
{
cout << "Welcome to Moe's Fable creater" << endl;
return;
}
string fable()
{
ifstream fableFilein;
int randNum;
string fable;
srand(time(NULL));
randNum = rand() % 5;
if(randNum == 0)
{
fableFilein.open("fable1.txt");
getline(fableFilein,fable);//takes the words of text file and makes it a string
fableFilein.close();
}
else if(randNum == 1)
{
fableFilein.open("fable2.txt");
getline(fableFilein,fable);
fableFilein.close();
}
else if(randNum == 2)
{
fableFilein.open("fable3.txt");
getline(fableFilein,fable);
fableFilein.close();
}
else if(randNum == 3)
{
fableFilein.open("fable4.txt");
getline(fableFilein,fable);
fableFilein.close();
}
else if(randNum == 4)
{
fableFilein.open("fable5.txt");
getline(fableFilein,fable);
fableFilein.close();
}
return fable;
}
void MoeRant()
{
int randNum2, a;
string rant;
ifstream rantsFilein;
srand(time(NULL));
randNum2 = rand() % 4;
a = rand() % 6;
if(randNum2 == 0)
{
rantsFilein.open("Moe-rants.txt");
do
{
getline(rantsFilein, rant);
}while(--a >= 0);//gets a random line from text file
rantsFilein.close();//ends the stream for that certain text file
cout << " " << rant << endl;
}
else
{
cout << " ";
}
return;
}
string Nouns1()
{
int a;
string nouns;
ifstream finNouns;
srand(time(NULL));
finNouns.open("list1.txt");
a = rand() % 14;
do
{
getline(finNouns,nouns);
}while(--a >= 0);
finNouns.close();
return nouns;
}
string Nouns2()
{
int a;
string noun;
ifstream finNoun;
srand(time(NULL));
finNoun.open("list2.txt");
a = static_cast<int>(rand() % 24);
do
{
getline(finNoun,noun);
}while(--a >= 0);
finNoun.close();
return noun;
}
void Moral()
{
ifstream finMoral;
string moral;
int a;
srand(time(NULL));
a = (rand() % 6) + 1;
cout << "\nThe Moe-rale of this story is: ";
finMoral.open("Moe-rals.txt");
do
{
getline(finMoral, moral);
}while(--a >= 0);
finMoral.close();
cout << moral << endl;
return;
}
string replaceNouns(string fable, string noun, string noun2)
{
int i = 0;
fable.c_str();
noun.c_str();
noun2.c_str();
while(&fable[i] != '\0')
{
if(strcpy(&fable[i],"boy") == 0 || strcpy(&fable[i],"ant") == 0 || strcpy(&fable[i],"fox") == 0 || strcpy(&fable[i],"man") == 0 || strcpy(&fable[i],"milkmaid") == 0)
{
fable[i] = noun[i];
}
else if(strcpy(&fable[i],"serpant") == 0 ||strcpy(&fable[i],"grasshopper") == 0 || strcpy(&fable[i],"goat") == 0 || strcpy(&fable[i],"trees") ==0 ||strcpy(&fable[i],"milkpail") == 0)
{
fable[i] = noun2[i];
}
}
return fable;
}
|