Need help with code asap

I have a class called TestScores. Within this class, I have another class called NegativeScore. What the class NegativeScore does is throw an exception. The exception being when a score is negative.

Here is the pertinent code:

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
29
30
31
32
33
34
35
36
37
38
39
class NegativeScore {

public:
    float negativeScore;

public:
    NegativeScore()
    {
        negativeScore = score ; //need this to happen
    }

    void setBadScore(float s)
    {
        negativeScore = s;
    }

    float getBadScore()
    {
        return negativeScore;
    }



};


void addScore(float score)
    {

        if (score < 0)
        {
            throw NegativeScore();
        }

       else
        studentScores.push_back(score);


    }


The addScore method is defined in TestScores class. What I need to do is set "score" defined in method addScore, which is in the TestScores class, equal to negativeScore, which is defined in the NegativeScore class. I have no idea how to go about this. Please help. Thanks.
NegativeScore should be an empty class nested within the TestScores class, then just throw the empty class.
Last edited on
Topic archived. No new replies allowed.