1.3-Object-Georienteerd-Programmeren

Chess pieces

What many people find difficult when learning chess is exactly which moves may be made by which piece. To help with this, we are going to draw a (simple) chess board showing the possible moves for a given chess piece.

We have already given you the outline of two classes: King and Pawn (representing their namesake pieces). We have already taken care of drawing the board and loading the correct images, so all you need to do is apply your knowledge about encapsulation on these files.

For both classes, do the following:

You will see that the method showMoves() uses the previous method. It is up to you to figure out what it does in more detail.

We recommend you start with the class Pawn.