Skip to content

Commit 20b9cc6

Browse files
authored
Merge pull request #3 from SOUComputerScience/keyattribute
Keyattribute
2 parents 25ef6dd + 7d9174b commit 20b9cc6

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,8 @@ def main():
111111
)
112112
)
113113

114+
for x in formula_one_2023.getTeamStandings():
115+
print(x)
116+
114117
if __name__ == "__main__":
115118
main()

src/championship/championship.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,15 @@ def getTeamStandings(self) -> List:
8888
returns:
8989
List
9090
'''
91-
# TODO
92-
pass
91+
sorted_standings = sorted(self.team_standings.items(), key=lambda x:x[1])
92+
sorted_standings.reverse()
93+
94+
printable = list()
95+
96+
for i in range(len(sorted_standings)):
97+
printable.append(f"{i+1}: {sorted_standings[i][0].name} ({sorted_standings[i][1]} points)")
98+
99+
return printable
93100

94101
def holdRace(self, race: Race, results: List[Driver]):
95102
'''

src/team/teamFactory.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
class TeamFactory:
77
@staticmethod
8-
def createTeam(self, name: str, engine: EngineInt | str, country: str, drivers: List(Driver)) -> Team:
8+
def createTeam(name: str, engine: EngineInt | str, country: str, drivers: List[Driver]) -> Team:
99
"""
1010
create a team with a custom engine
1111
@@ -27,7 +27,7 @@ def createTeam(self, name: str, engine: EngineInt | str, country: str, drivers:
2727
return Team(name = name, engine = engine, country = country, drivers = drivers)
2828

2929
@staticmethod
30-
def createTeamFerrariEngine(self, name: str, country: str, drivers: List(Driver)) -> Team:
30+
def createTeamFerrariEngine(name: str, country: str, drivers: List[Driver]) -> Team:
3131
"""
3232
create a team with a Ferrari engine
3333
@@ -44,7 +44,7 @@ def createTeamFerrariEngine(self, name: str, country: str, drivers: List(Driver)
4444
return Team(name = name, engine = FerrariEngine(), country = country, drivers = drivers)
4545

4646
@staticmethod
47-
def createTeamHondaRBPTEngine(self, name: str, country: str, drivers: List(Driver)) -> Team:
47+
def createTeamHondaRBPTEngine(name: str, country: str, drivers: List[Driver]) -> Team:
4848
"""
4949
create a team with a Honda Red Bull Power Trains engine
5050
@@ -61,7 +61,7 @@ def createTeamHondaRBPTEngine(self, name: str, country: str, drivers: List(Drive
6161
return Team(name = name, engine = HondaRBPTEngine(), country = country, drivers = drivers)
6262

6363
@staticmethod
64-
def createTeamMercedesEngine(self, name: str, country: str, drivers: List(Driver)) -> Team:
64+
def createTeamMercedesEngine(name: str, country: str, drivers: List[Driver]) -> Team:
6565
"""
6666
create a team with a Mercedes engine
6767
@@ -78,7 +78,7 @@ def createTeamMercedesEngine(self, name: str, country: str, drivers: List(Driver
7878
return Team(name = name, engine = MercedesEngine(), country = country, drivers = drivers)
7979

8080
@staticmethod
81-
def createTeamRenaultEngine(self, name: str, country: str, drivers: List(Driver)) -> Team:
81+
def createTeamRenaultEngine(name: str, country: str, drivers: List[Driver]) -> Team:
8282
"""
8383
create a team with a Renault engine
8484

0 commit comments

Comments
 (0)