Untitled
unknown
plain_text
9 months ago
923 B
6
Indexable
Class fortnite.
def __init__(self):
self.players = []
self.map = "Battle Royale Island"
self.game_state = "Waiting for players"
def add_players(self, player_name):
self.players.append(player_name)
print(f"{player_name} has joined the game.")
def start_game(self):
if len(self.players) < 2:
print("Not enough players to start the game .")
else:
self.game_state = "In Progress"
print("The game has started!")
def end_game(self):
self.game_state = "Finished"
print("The game has ended.")
self.players.clear()
def display_status(self):
print(f" Current game state: {self.game_state}")
print(f"Players in the game: {', '.join(self.players) if self players else 'No players'}")
fortnite_game = Fortnite()
fortnite_game.add_player("Player1")
fortnine_game.add_player("Player2")Editor is loading...
Leave a Comment