Design a Chessboard (Chess Game Design)

viaGlassdoor

Requirements: Design the classes/data structures to represent a chessboard and the pieces on it, sufficient to support querying and moving pieces.

Design: Model a Board as an 8x8 grid of Square/Cell objects, each optionally holding a Piece. Define a Piece base class/interface (King, Queen, Rook, Bishop, Knight, Pawn as subclasses or a single class with a type enum), each knowing its own legal-move generation logic. The Board exposes movePiece(from, to) which validates the move against the piece's rules and current board state (check/checkmate detection can be layered on top as a follow-up).

Add a follow-up question they asked
No follow-ups yet. Be the first to add one.
asked …
LeaderboardSalary
Language
Account