''' DS2500 Spring 2025 Sample code from lecture -- a class to rep a Hockey Team 1/14/25 Possible attributes: * # wins * # losses * ticket sales * seconds of posession * shots * goals/points * home games / away games * # power plays * city * team name * starting line up * (Maybe we should add a Player class?) Possible methods: * scoring efficiency * unit conversions * plotting ''' import matplotlib.pyplot as plt class HockeyTeam: def __init__(self, city, w, l): self.city = city self.wins = w self.losses = l def plot_team(self): ''' plot the team's wins vs losses ''' plt.bar(1, self.wins, color = "pink") plt.bar(2, self.losses, color = "magenta") plt.title(f"{self.city} Wins vs Losses 2023-2024") # plt.xticks takes: list of positions, list of labels plt.xticks([1, 2], ["Wins", "Losses"]) plt.show() def is_better(self, other): ''' is current team better than other team? compare ratio of wins/losses''' if self.wins / self.losses > other.wins / other.losses: return True return False def __str__(self): ''' return a string that should print ''' return self.city + "!"