Loading…
Loading…
Every piece type moves differently, but they're all still "a piece on a board that can be asked for its valid moves." What relationship between Piece and its subtypes (Pawn, Rook, …) makes "ask any piece for its valid moves" work without the board needing a giant switch statement on piece type?
Design your own solution first — on paper, a whiteboard, or your own IDE — before checking the reference.