Who wants to be a millionaire Class help

Hey I'm working on making Who wants to be a millionaire for my c++ class, was wondering if you had any tips i'm having trouble with what to do on the Lifeline class(parent) and Ask the Audience (child class) and how to implement them using code.

Lifeline class
The lifeline class provides the following functionality:
 Lifeline()
◦ This is the default constructor and should set all attributes (private and protected) to default values
 Lifeline(string n)
◦ This is an overloaded constructor and should set name attribute to the corresponding value passed into the constructor
and the used attribute to its default value.
 string getName()
◦ This function returns the name attribute
 bool isAvailable()
◦ This function returns the true if the used attribute is false. False otherwise.
 void use(Question& question)
◦ This function prints the message “Lifeline class – Use function” to the screen

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Lifeline
{
    private:
        string name;

    protected:
        bool used;

    public:
        Lifeline();
        Lifeline(string n);

        string getName();
        bool isAvailable();

        void use(Question& question);


};

CallAFriend class
The callAFriend class provides the following functionality:
 CallAFriend ()
◦ This is the default constructor and should set the name attribute to the value “Call a friend”
 void use(Question& question)
◦ This function implements the usage of the lifeline “Call a friend”. Note that this function overrides the definition of
the use method of its parent class.
◦ 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
class CallAFriend : public Lifeline
{
    public:
        CallAFriend();
        void use(Question& question);
};

Last edited on
Topic archived. No new replies allowed.