Ask a Friend lifeline class help

Trying to figure out this CallAFriend class, any suggestions? My code is set somewhat random just trying to set up some of the main functions.

◦ If this lifeline is already used this function should terminate.
◦ This function should display the likelihood of the answers choices being correct (as a percentage) according to your
friend.
▪ First, randomly pick whether the your friend is correct (i.e. Your friend picked the correct answer). Your friend is
correct 50% of the time.
▪ If your friend is correct, randomly assign the correct answer choice a percentage between 50% and 100%.
▪ If your friend is not correct (i.e. Your friend did not pick the correct answer), randomly assign the correct answer
choice a percentage between 0% and 50%.
▪ Now from the remaining percentage (100% - percentage assigned to your friends answer), randomly assign
percentages to the three remaining answers. First randomly pick an integer between 0 -100 for each answer
choice. Then, use the following formula to determine the randomly assigned percentage for each answer choice.
 remainingAnswerPercentage = random1*remainingPercentage/(random1+random2+random3)
▪ Once you have determined the percentages append them to their corresponding answer choices.
 Note that the percentages calculated are decimals (floating point numbers). You need to convert them to
strings before you append them to their corresponding answer choices. You can use an stringstream
variable for this. Refer the hints section to find out how to convert a floating-point number to a string.
▪ Finally, set the used attribute to true to signify that the “Call a friend” lifeline has now been used.
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
CallAFriend::CallAFriend():Lifeline()
{
    name="Call A Friend";
}
void CallAFriend::use(Question& question)
{
    if(CallAFriend()==used)
    {
        vector<int> v;
        v.push_back(10); v.push_back(20); v.push_back(30);
        v.erase(v.begin()+2)
        return;
    }
    else
    {
        int random;
        double percent=75;
        
        srand(time(NULL));
        random = rand() % 10;
        
        stringstream s;
        s << percent;
        question.getAnswers().at(i) += s.str();
        
    
    }
}


Appreciate any help!
Oh and by the way the vector push back and erase function is to delete it once it's been used, its a lifeline for a game similar to who wants to be a millionaire.
Last edited on
Topic archived. No new replies allowed.