Bird
0
0
LLDsystem_design~10 mins

Board, Player, Game classes in LLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the Player class with a name attribute.

LLD
class Player:
    def __init__(self, [1]):
        self.name = name
Drag options to blanks, or click blank then click option'
Aid
Bplayer_name
Cscore
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different parameter name than the attribute without assignment.
Forgetting to include the parameter in the constructor.
2fill in blank
medium

Complete the code to initialize the Board class with a size attribute.

LLD
class Board:
    def __init__(self, [1]):
        self.size = size
Drag options to blanks, or click blank then click option'
Adimension
Bsize
Cwidth
Dlength
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different parameter name without assigning it to the attribute.
Forgetting to pass the parameter when creating the Board object.
3fill in blank
hard

Fix the error in the Game class constructor to correctly initialize players list.

LLD
class Game:
    def __init__(self):
        self.players = [1]
Drag options to blanks, or click blank then click option'
A[]
BPlayer()
C{}
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Initializing players as a single Player object instead of a list.
Using a dictionary or None instead of a list.
4fill in blank
hard

Fill both blanks to add a player to the game and print the player's name.

LLD
def add_player(self, player):
    self.players.[1](player)
    print(f"Player {player.[2] added")
Drag options to blanks, or click blank then click option'
Aappend
Bremove
Cname
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using remove instead of append.
Printing player.id instead of player.name.
5fill in blank
hard

Fill all three blanks to initialize the game with a board and two players.

LLD
def start_game(self, board_size, player1_name, player2_name):
    self.board = Board([1])
    self.players = [Player([2]), Player([3])]
Drag options to blanks, or click blank then click option'
Aboard_size
Bplayer1_name
Cplayer2_name
Dsize
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect variable names for board size or player names.
Mixing up player1 and player2 names.