Skip to main content

Practice · 3 of 3

The scoreboard with fouls

CHALLENGE
Difficulty: advanced+25 XP

Implement the Scoreboard class: constructor stores both team names. score(team, points) adds points to that team (ignore unknown team names). foul(team) records a foul for that team; when a team reaches **5 fouls**, the opponent immediately gains 2 bonus points (the 6th foul does nothing extra). leader() returns the leading team's name, or the **home** team's name on a tie.

Back to lesson: Practice: State machine lab