Advertisement
horozov86

class_Team_Footbal_Team_Generator

Jul 6th, 2023
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. class Team:
  2.     def __init__(self, name, rating):
  3.         self.__name = name
  4.         self.__rating = rating
  5.         self.__players = []
  6.        
  7.     def add_player(self, player: Player):
  8.         if player in self.__players:
  9.             return f"Player {player.name} has already joined"
  10.         self.__players.append(player)
  11.         return f"Player {player.name} joined team {self.__name}"
  12.        
  13.     def remove_player(self, player_name):
  14.         for player in self.__players:
  15.             if player.name == player_name:
  16.                 self.__players.remove(player)
  17.                 return player
  18.         return f"Player {player_name} not found"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement