Grokking the Object Oriented Design Interview
Vote

0% completed

​

Design Chess

.....

.....

.....

Like the course? Get enrolled and start learning!
A

Anonymous

· 2 years ago

  1. The Knight and King classes both have the following code to see if the end box has a Piece of the same colour as the King. If the Box is empty however, wouldn't getPiece return null, and in return throw an error when isWhite is called on it?
if (end.getPiece().isWhite() == this.isWhite()) { return false; }
  1. The boxes matrix is never initialized in the Board class, so "resetting" the board in the constructor will cause a null pointer exception.

Reading Progress

0%


Vote for new content