tresinformal / basketball

Trêsinformal's 2024 team basketball game
GNU General Public License v3.0
0 stars 0 forks source link

A player that scores increase its score count #39

Closed TheoPannetier closed 8 months ago

TheoPannetier commented 11 months ago

Depends on:

When a player scores, it gains either:


       // 39 - A player that scores increase its score count
        // by 2 points if inside the line
        // by 3 points if outside the line

        player p;
        const int line_x_position = 30; // arbitrary value

        // the player is inside the line
        p.set_position(line_x_position - 30); // inside is below the line's x, arbitrary

        // it scores
        p.score(line_x_position);
        // now its score should be 2
        assert(p.get_score() == 2);
        // it scores again
        p.score(line_x_position);
        // now its score should be 4
        assert(p.get_score() == 4);
        // the player is now outside the line
        p.set_position(line_x_position + 30);

        // it scores
        p.score(line_x_position);
        // its score should now be 7
        assert(p.get_score() == 7);