NeetCode - Object-Oriented Design Interview

NeetCode - Object-Oriented Design Interview

Register & Get access to index

screenshot-94.png
Requirements​

Some possible questions to ask:

  • What are the rules of the game?
  • What size is the grid?
  • How many players are there? Player vs Computer? Player vs Player?
  • Are we keeping track of the score?

Basics​

  • The game will be played by only two players, player vs player
  • The game board should be of variable dimensions
  • The target is to connect N discs in a row (vertically, horizontally or diagonally)
    • N is a variable (e.g. connect 4, 5, 6, etc)
  • There should be a score tracking system
    • After a player reaches the target score, they are the winner

Design​

High-level​

  • We will need a Gridclass to maintain the state of the 2-D board
    • The board cell can be empty, yellow (occupied by Player 1) or red (occupied by Player 2)
    • The grid will also be responsible for checking for a win condition
  • We can have a Playerclass to represent the player's piece color
    • This isn't super important, but encapsulating information is generally a good practice
  • The Game class will be composed of the Grid and Players
    • The Game class will be responsible for the game loop and keeping track of the score
Author
Satoru Gojo
Downloads
1,050
Views
5,087
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from Satoru Gojo

Latest updates

  1. New Update

    Course Updated 11-2023