Cclass Model { int health; void damage() { health--; } } class View { void render(Model m) { print(m.health); } }
Dclass Model { int score; void display() { print(score); } } class View { void update() { score++; } }
Step-by-Step Solution
Solution:
Step 1: Identify separation
Model holds data and logic; View handles display using model data.
Step 2: Analyze options
class Model { int health; void damage() { health--; } } class View { void render(Model m) { print(m.health); } } cleanly separates model logic and view rendering.
Final Answer:
class Model { int health; void damage() { health--; } } class View { void render(Model m) { print(m.health); } } correctly shows model-view separation.
Quick Check:
Model updates data; view reads data to render [OK]
Quick Trick:Model holds data; view reads data to display [OK]
Common Mistakes:
MISTAKES
Combining model and view in one class
View modifying model data
Model handling rendering
Master "Design — Tic-Tac-Toe Game" in LLD
9 interactive learning modes - each teaches the same concept differently