---
# System prepended metadata

title: Untitled

---

Design a system for playing a game of Tic Tac Toe. The initial requirements are that

- it supports playing a game between two human players,
- the two players are remote from one another (i.e. game is over the internet, and necessarily the web though)
- the UI doesn't matter (i.e. could be HTML, a console, a mobile app, or a desktop app)
- your budget is tight, you want to keep spend as low as possible

Thoughts
- This looks like array
- I need a inputs for both players
- I need to check the values of the previous entry in the array
- I need to check if the values match up horizontally, vertically, diagonally, this will lead to 8 possiblities
### Example
```
Class SpaceInvader
- Atributes:
  - is_destroyed - boolean # Is the ship destoryed
  - speed - int # How fast this moves across the screen
methods:
  - Private Move - Moves the piece over spaces at the speed
  - shoot - Shoots a laser beam down at the player
```

```
    Class TickTacToe
        constructor
            set Player values, meaning who is X who is O
        private entries (array)
        public getNextUserInput
          while Loop
            userInputPrompt
          Loop End
            checkForWinner
        private userInputPrompt
           check to make sure user is putting the right value either for their entry (sanitize entries)
           addEntry
        private checkForWinner
           add logic to run through matching possibities
        public displayWhichPlayerWon
           check to see which player won as O or X or its a draw

Class Network:          
   methods:
     - Public EstablishNetworkForPlayerA - This will get player A's connection to the server
     - Public EstablishNetworkForPlayerB - This will get player B's connection to the server
     - Public NotifyNextPlayer - This will notify the next player once the previous player has added their entry to the game
     - Public NotifyAllPlayers - This will notify all players of the result of the game
     - Public StartANewGame - This will start a new game session
     
Class GameManager
   methods:
     - Public Login - Establishes a stateless session to the game
     - Public Registration - Adds new user to a database 
     - 
     - Private CheckUsers - Check to see if they are any available users that would like to play the game
     - Private MatchupSort - This can be a logic to match user based on skill level, and experience for optimal play
     - Public ShowListOfNewGamesToPlay
        - TickTacToe Game
        - Monopoly 
     - Private RecordWinnerLoss
     - Public GameLeaderBoard - This will retrieve the list game leaders base on the number of wins that they have. Sorted by the highest matches winner
     - Public GameRooms - This will have a list of active games, be able to view the game session between the two users, this will be an active push to UI, API
     
```

```
X O
 X
X O
```

> Write a function that will make the next move on a given board,
where next move must be "fills in any available space" / Random space?