3.1 The inheritance relationship
For example, there are 32 chess pieces in our chess set, but there are only six different types of pieces (pawns, rooks, bishops, knights, king, and queen). Each type behaves differently when it is moved. Each of these piece classes have properties, such as the color and the chess set they are part of, but they also have unique shapes when drawn on the chess board, and make different moves.
Figure 3.1 shows how the six types of pieces can inherit from a Piece class:
The hollow arrows indicate that the individual classes of pieces inherit from the Piece class. All the child classes automatically have a chess_set and color attribute inherited from the base class. Each piece provides a different shape property (to be drawn on the screen when rendering the board), and a different move method to move the piece to a new position on the...