In a board game design, which class should be the base class to represent all pieces on the board?
Think about what all pieces share regardless of type.
The Piece class is the base because it represents common properties and behaviors for all pieces, such as position and movement rules.
Which design choice best supports a scalable board that can handle different game types and sizes?
Consider flexibility for different board sizes and shapes.
A dynamic data structure keyed by coordinates allows the board to adapt to various sizes and shapes, supporting multiple game types.
For a complex game with many piece types and movement rules, which approach best scales validation logic?
Think about how to keep code organized and easy to extend.
Using polymorphism lets each piece class handle its own movement rules, making the system modular and easier to maintain as new pieces are added.
Which design choice balances flexibility and code reuse when pieces have multiple abilities?
Consider how to add or remove abilities without rewriting classes.
Composition allows abilities to be modular and reusable, avoiding rigid inheritance hierarchies and code duplication.
Estimate the approximate memory needed to store the state of a 100x100 board with 10,000 pieces, each piece storing position (2 integers), type (1 byte), and owner (1 byte). Assume 4 bytes per integer and ignore overhead.
Calculate bytes per piece and multiply by number of pieces.
Each piece: 2 integers (4+4=8 bytes) + type (1 byte) + owner (1 byte) = 10 bytes. 10,000 pieces × 10 bytes = 100,000 bytes ≈ 100 KB (C).