CMU 15-110: Principles of Computing
2d Board Games
In class today, we will review board-game-starter-code.py and then board-game-basic-example.py.
Some vocabulary:
- This is an example of the MVC (Model-View-Controller) design pattern
- Model: the values in
data
and the code to manipulate that data - View: the code to present or view the model to the user (in our code, in
drawAll
) - Controller: the code to respond to events by updating the model (in our code, in
keyPressed
,mousePressed
,timerFired
, andinit
)
- These classes:
Cell
Bounds
BoardGame
- This function:
make2dList
- These functions:
getCellBounds
(and why it is akamodelToView
)getCell
(and why it is akaviewToModel
)
- The Model:
data.boardGame
-- why it is aBoardGame
instance and how it is used.data.boardGame.board
-- why it is a 2d List and how it is used to store the cells, and the counts inside each cell.data.selection
-- why it is aCell
instance and how it is used.
- The View:
drawAll
- The Controller:
init
keyPressed
mousePressed