This is my second time taking C++ course and I'm about to fail again since I'm barely hanging on with a C-D grade percentage. Here is the problem. I'm using the book "Beginning C++ Through Game Programming - 2nd Edition" and Dev-C++ to compile code.

I'm not even majoring in Computer Science so Programming is just not me. If anyone could make this work I'd appreciate it in advance, thanks. :'(

Rewrite the Mad Lib Game, so that there is a new object, a storyWordManager object, instantiated from a StoryWordManager class. The madLib object will be given a pointer to the storyWordManager object as a parameter that is passed into the MadLib constructor. The storyWordManager object's constructor method will prompt the user for the necessary story words (or numbers) and will accept input from the cin object. The madLib object will invoke public "get" methods to access the necessary story words as the story is built and "told".

#include <iostream>
#include <string>

using namespace std;

// pass constant reference instead of copy of string object
string askText(const string& prompt);
int askNumber(const string& prompt);
void tellStory(const string& name, 
               const string& noun, 
               int number, 
               const string& bodyPart, 
               const string& verb);

int main()
{
    cout << "Welcome to Mad Lib.\n\n";
    cout << "Answer the following questions to help create a new story.\n";
    
    string name = askText("Please enter a name: ");
    string noun = askText("Please enter a plural noun: ");
    int number = askNumber("Please enter a number: ");
    string bodyPart = askText("Please enter a body part: ");
    string verb = askText("Please enter a verb: ");
    
    tellStory(name, noun, number, bodyPart, verb);

    return 0;
}

string askText(const string& prompt)
{
    string text;
    cout << prompt;
    cin >> text; 
    return text;
}

int askNumber(const string& prompt)
{
    int num;
    cout << prompt;
    cin >> num;
    return num;
}

void tellStory(const string& name, 
               const string& noun, 
               int number, 
               const string& bodyPart, 
               const string& verb)
{
    cout << "\nHere's your story:\n";
    cout << "The famous explorer ";
    cout << name;
    cout << " had nearly given up a life-long quest to find\n";
    cout << "The Lost City of ";
    cout << noun;
    cout << " when one day, the ";
    cout << noun;
    cout << " found the explorer.\n";
    cout << "Surrounded by ";
    cout << number;
    cout << " " << noun;
    cout << ", a tear came to ";
    cout << name << "'s ";
    cout << bodyPart << ".\n";
    cout << "After all this time, the quest was finally over. ";
    cout << "And then, the ";
    cout << noun << "\n";
    cout << "promptly devoured ";
    cout << name << ". ";
    cout << "The moral of the story? Be careful what you ";
    cout << verb;
    cout << " for.";
    
    system("pause");
    
}
class StoryWordManager {
string askText(const string& prompt);
int askNumber(const string& prompt);

};
int main(int argc,char *argv[]) {

}

That is an easy homework.

This is my second time taking C++ course and I'm about to fail again since I'm barely hanging on with a C-D grade percentage. Here is the problem. I'm using the book "Beginning C++ Through Game Programming - 2nd Edition" and Dev-C++ to compile code.

I'm not even majoring in Computer Science so Programming is just not me. If anyone could make this work I'd appreciate it in advance, thanks. :'(

Rewrite the Mad Lib Game, so that there is a new object, a storyWordManager object, instantiated from a StoryWordManager class. The madLib object will be given a pointer to the storyWordManager object as a parameter that is passed into the MadLib constructor. The storyWordManager object's constructor method will prompt the user for the necessary story words (or numbers) and will accept input from the cin object. The madLib object will invoke public "get" methods to access the necessary story words as the story is built and "told".

What is the question? You have explained your situation and your desire for some one to "make this work", and you have posted your code and the assignment, but you have not asked a specific question and you have not said what works, what doesn't, what you've tried, what the results are, etc. If your hope is that someone will read the assignment, change your code to reflect the assignment criteria, then post the completed program, that isn't going to happen here. You need to ask a more specific question. People will help you, but they won't do the whole thing for you.

class StoryWordManager {
string askText(const string& prompt);
int askNumber(const string& prompt);

};
int main(int argc,char *argv[]) {

}

That is an easy homework.

Ok Boss this is what I have. Now here is the thing I got now, is this correct or is there something else I'm missing here? Please Boss help me! :icon_confused:

#include <iostream>
#include <string>

using namespace std;
              
string askText(const string* const prompt);
int askNumber(const string* const prompt);
void tellStory(const string* const name, const string* const noun, int number, const string* const bodyPart, const string* const verb);


main()
{
    cout << "Welcome to Mad Lib.\n\n";
    cout << "Answer the following questions to help create a new story.\n";       
    string prompt = "Please enter a name: ";
    string name = askText(&prompt);   
    prompt = "Please enter a plural noun: ";
    string noun = askText(&prompt);    
    prompt = "Please enter a number: ";
    int number = askNumber(&prompt);   
    prompt = "Please enter a body part: ";
    string bodyPart = askText(&prompt);
    prompt = "Please enter a verb: ";
    string verb = askText(&prompt);    
    tellStory(&name, &noun, number, &bodyPart, &verb);
    int x; cin >> x;
    return 0;
}

string askText(const string* const prompt)
{
    string text;
    cout << *prompt;
    cin >> text; 
    return text;
}

int askNumber(const string* const prompt)
{
    int num;
    cout << *prompt;
    cin >> num;
    return num;
}

void tellStory(const string* const name, const string* const noun, int number, const string* const bodyPart, const string* const verb)

{
    cout << "\nHere's your story:\n";
    cout << "The famous explorer ";
    cout << *name;
    cout << " had nearly given up a life-long quest to find\n";
    cout << "The Lost City of ";
    cout << *noun;
    cout << " when one day, the ";
    cout << *noun;
    cout << " found the explorer.\n";
    cout << "Surrounded by ";
    cout << number;
    cout << " " << *noun;
    cout << ", a tear came to ";
    cout << *name << "'s ";
    cout << *bodyPart << ".\n";
    cout << "After all this time, the quest was finally over. ";
    cout << "And then, the ";
    cout << *noun << "\n";
    cout << "promptly devoured ";
    cout << *name << ". ";
    cout << "The moral of the story? Be careful what you ";
    cout << *verb;
    cout << " for.";
}

Yes, there is something missing:

Rewrite the Mad Lib Game, so that there is a new object, a storyWordManager object, instantiated from a StoryWordManager class. The madLib object will be given a pointer to the storyWordManager object as a parameter that is passed into the MadLib constructor. The storyWordManager object's constructor method will prompt the user for the necessary story words (or numbers) and will accept input from the cin object. The madLib object will invoke public "get" methods to access the necessary story words as the story is built and "told".

You don't have a StoryWordManager class or a MadLib class and you don't have any constructors and you don't have any "get" methods. Are these classes something you are supposed to code from scratch or were they provided for you?

A fellow mate from class gave me that code, he's been working on. I posted it here to see if it was correct or not.

A fellow mate from class gave me that code, he's been working on. I posted it here to see if it was correct or not.

So, you wanted to hand in some else's piece of crap as your own ?? Don't you think your instructor will notice the resemblence?

Nope he doesn't mind. He actually encourages us to work together on projects, the classmates has partnered up but weeks gone by and many people drop the course so its getting harder and harder to work alone now. There is only 5 people left and only 1 out of 5 is probable to passing out of all of us. -__-

In that case why don't all 5 of you form a group and do the project as a group? You could each code the part you know how to code. But it might be too late for you all to do that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.