Thread: A little program I wrote for fun !

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657

    A little program I wrote for fun !

    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();
    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;
     }
    The implementations(attached the file because it is about 80 lines) :
    functions.cpp
    Last edited by manasij7479; 07-21-2011 at 06:23 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Just wrote my first Curses program
    By guesst in forum Linux Programming
    Replies: 14
    Last Post: 04-02-2008, 10:44 AM
  2. filesplitting program I wrote
    By movl0x1 in forum C Programming
    Replies: 7
    Last Post: 05-30-2007, 03:24 PM
  3. Can someone look over the program I wrote?
    By brooklyn in forum C++ Programming
    Replies: 10
    Last Post: 04-16-2006, 07:23 AM
  4. Replies: 2
    Last Post: 04-25-2005, 11:59 AM
  5. wrote a program; please review/comment
    By spirited in forum C++ Programming
    Replies: 4
    Last Post: 05-22-2003, 01:37 PM