NCC Summer 17 Game Camp
Networked Tic Tac Toe

In this session, you will fill in missing code to complete a partially written Tic Tac Toe game. Start by downloading a zipped folder that contains the game at this link.

Unzip the folder by right-clicking on it and selecting the option "extract here" from the context menu.

Next, navigate into the NetTTT2013 folder and double-click on the file NetTTT2013.sln. This should be the file with the purple icon that looks like a bow-tie. This action should cause Visual Studio to open up.

You should now be looking at the project in Visual Studio. You can right-click on the Form1.vb icon in the solution explorer and use the resulting pop-up menu to switch back and forth between design view and code view.

Switch to code view. Move toward the end of the file, and find the method (subroutine)

 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)_ 
          Handles Button2.Click, Button1.Click, Button3.Click, Button4.Click, _
                  Button5.Click, Button6.Click, Button7.Click, Button8.Click, _

        Dim clicked As Button = sender

        'Check if game is over  (use the variable gameOver),
        'Is so, output a message and return

        'Check if it is the local player's turn, if not,
        'output a message to wait for your turn and return

        'Record the move made by the Local Player: Use the string variable playerId
        'And disable the cell that was clicked.

        'Increase number of turns played

        'Send move to remote player
        StatusBar1.Text = "Wait for your turn."

        'Check to see if the local player has won, use hasWon(String p) function
        'If the local player has won, output a congratulatory message and return

        If Me.hasWon(playerId) Then
            MessageBox.Show(playerId & " Has won!")
            StatusBar1.Text = "Game is over."
            gameOver = True
        End If

        'Check to see if the game is tied. Is so the game is over.
        'Make sure to update status bar

        'Flip the turn so the remote player can play

    End Sub

This is the method you have to complete. This is the method that handles the click events on the buttons that will hold the Xs and Os when they are clicked by the user to play the game. Study the comments that explain the missing steps, and then figure out how to write Visual Basic statements to fill in those steps.

When you have finished filling in the missing pieces, find someone who also has finished their program. Find out the IP addresses on each other's computers, appoint one person to be the server, and then play the networked version of Tic Tac Toe.