Hey (...)
I know it could be considered somewhat arrogant to do this, but I'm just asking for some helpful 'reviews' of the following short program.
The program takes a yes/no Question and gives a random answer to it, remaining grammatically correct.
It works as expected, but there could be 'bad' code within it...that's the reason.
The functions used are:
std::string auxiliary_p(std::string);
std::string find_pronoun(std::string);
bool answer(std::string);
std::string modify(bool,std::string,std::string);
bool quit_condition();
The implementations(attached the file because it is about 80 lines) :Code:#include<iostream> #include "functions.h" using namespace std; int main() { string input,pronoun,auxiliary,output; bool yes_or_no; do { cout<<"Input: "; getline(cin,input); auxiliary=auxiliary_p(input); //Gets the auxiliary verb pronoun=find_pronoun(input); // Gets the pronoun if(auxiliary=="NULL"||pronoun=="NULL") { cout<<"Try Again ."<<endl; continue; } yes_or_no = answer(input); output=modify(yes_or_no,pronoun,auxiliary); //Attaches n't and/or puts yes/no cout<<"Output: "<<output<<endl; } while(quit_condition()); return 0; }
functions.cpp