Last active
June 26, 2026 02:34
-
-
Save mcsee/5af41b0cba3f5bafc18316a8f231a011 to your computer and use it in GitHub Desktop.
Loop Iteration 2 - Minimal implementation: Team, Match, GroupStandings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Team: | |
| def __init__(self, name): | |
| self.name = name | |
| class Match: | |
| def __init__(self, home, away, home_goals, away_goals): | |
| self.home = home | |
| self.away = away | |
| self.home_goals = home_goals | |
| self.away_goals = away_goals | |
| class GroupStandings: | |
| def __init__(self): | |
| self._points = {} | |
| def record(self, match): | |
| if match.home_goals > match.away_goals: | |
| self._points[match.home] = | |
| self._points.get(match.home, 0) + 3 | |
| self._points[match.away] = | |
| self._points.get(match.away, 0) | |
| elif match.away_goals > match.home_goals: | |
| self._points[match.away] = | |
| self._points.get(match.away, 0) + 3 | |
| self._points[match.home] = | |
| self._points.get(match.home, 0) | |
| def points_for(self, team): | |
| return self._points.get(team, 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment