Grokking the Object Oriented Design Interview
Vote
0% completed
Design Chess
Let's design a system to play online chess.
Chess is a two-player strategy board game. It is played on a chessboard, a checkered board with 64 squares in an 8x8 grid. People play a few versions of the game all over the world. In this design problem, we focus on a two-player online chess game.
System Requirements
We will focus on these requirements while designing the game of chess:
-
The system should support two online players playing a game of chess.
-
All rules of international chess will be followed.
-
Each player is randomly assigned a side, black or white.
4
.....
.....
.....
Like the course? Get enrolled and start learning!
A
akshayavb99
· 2 years ago
What does it mean when a class has a function with same name as the class?
class Board:
def init(self):
self.__boxes = [[]]
def Board(self):
self.reset_board()
E H
· 2 years ago
- 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; }
- 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%