Bird
0
0
LLDsystem_design~10 mins

Why game design tests model-view separation in LLD - Test Your Understanding

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

Complete the code to separate the game state from the display logic.

LLD
class GameModel:
    def __init__(self):
        self.score = 0

class GameView:
    def display_score(self, model):
        print('Score:', model.[1])
Drag options to blanks, or click blank then click option'
Ascore
Bdisplay
Cstate
Dupdate
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to call a method that doesn't exist in the model.
Accessing a wrong attribute name.
2fill in blank
medium

Complete the code to update the game model without changing the view.

LLD
class GameModel:
    def __init__(self):
        self.lives = 3

    def lose_life(self):
        self.[1] -= 1
Drag options to blanks, or click blank then click option'
Ascore
Bhealth
Clives
Dlevel
Attempts:
3 left
💡 Hint
Common Mistakes
Decreasing an unrelated attribute like score or health.
Using a method name instead of an attribute.
3fill in blank
hard

Fix the error in the view code that incorrectly modifies the model.

LLD
class GameView:
    def update_score(self, model, points):
        model.[1] = points  # Incorrect: view should not modify model directly
Drag options to blanks, or click blank then click option'
Ascore
Blives
Clevel
Dstate
Attempts:
3 left
💡 Hint
Common Mistakes
Modifying model attributes inside the view.
Confusing model and view responsibilities.
4fill in blank
hard

Fill both blanks to implement a controller method that updates the model and triggers the view update.

LLD
class GameController:
    def __init__(self, model, view):
        self.model = model
        self.view = view

    def add_points(self, points):
        self.model.[1] += points
        self.view.display_score(self.model.[2])
Drag options to blanks, or click blank then click option'
Ascore
Blives
Dlevel
Attempts:
3 left
💡 Hint
Common Mistakes
Using different attributes for update and display.
Mixing up model and view roles.
5fill in blank
hard

Fill all three blanks to complete the MVC pattern: model update, view display, and controller method name.

LLD
class GameController:
    def [1](self, points):
        self.model.[2] += points
        self.view.[3](self.model)
Drag options to blanks, or click blank then click option'
Aadd_points
Bscore
Cdisplay_score
Dupdate_score
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong method names that don't fit MVC.
Updating view instead of model.