Several months ago, I was asked to create a small Java library that can be accessed by an application to render a graphical user interface (GUI) for the game of Checkers. As well as rendering a checkerboard and checkers, the GUI must allow a checker to be dragged from one square to another. Also, a checker must be centered on a square and must not be assigned to a square that's occupied by another checker. In this post, I present my library.
Designing a Checkers GUI Library
What public types should the library support? In checkers, each of two players alternately moves one of its regular (non-king) checkers over a board in a forward direction only and possibly jumps the other player's checker(s). When the checker reaches the other side, it's promoted to a king, which can also move in a backwards direction. From this description, we can infer the following types: