It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

tic tac toe game

Moderator: dafunkymunky

tic tac toe game

Postby marmoora on Sat May 01, 2010 2:11 am

hey im totali new to this andi really need somone's help pleeeeez
here is my problem, im new to visual basic and we have been asked to design a program that allows two players to play a game of tic tac toe.

we have to use two-dimentional string array with three rows and three columns as the game board. and each element of the array should be initialised with an astrisk (*).

so the program should display the content of the board array.
the program should ask the user to select a row and column number.

here is what i have come up with:
Module Module1

Sub Main()
' Create a 2D array (not implemented atm)
Const MAX_ROW As Integer = 2
Const MAX_COL As Integer = 2

' Counter variables for rows and columns
Dim row, col As Integer 'Useless atm
Dim value1 As Integer
Dim value2 As Integer
Dim value3 As Integer

' Welcome user to tic tac toe
Console.WriteLine("Welcome to tic tac toe")
Console.WriteLine(" | | ")
Console.WriteLine("--- --- ---")
Console.WriteLine(" | | ")
Console.WriteLine("--- --- ---")
Console.WriteLine(" | | ")

' Get values to store in the array
Console.Write("Player 1: Enter a co-ordinate")
value1 = Console.ReadLine()

If value1 = "11" Then
Console.WriteLine(" X | | ")
Console.WriteLine("--- --- ---")
Console.WriteLine(" | | ")
Console.WriteLine("--- --- ---")
Console.WriteLine(" | | ")
End If

If value1 = "12" Then
Console.WriteLine(" | X | ")
Console.WriteLine("--- --- ---")
Console.WriteLine(" | | ")
Console.WriteLine("--- --- ---")
Console.WriteLine(" | | ")
End If

If value1 = "13" Then
Console.WriteLine(" | | X ")
Console.WriteLine("--- --- ---")
Console.WriteLine(" | | ")
Console.WriteLine("--- --- ---")
Console.WriteLine(" | | ")
End If

etcccc...

im afraid this is not using 2d array this is what i am having trouble with. im not sure how to set it up in order to use 2d array and as wel initialise element of the array with an asterisk (*)


pleeeeeeeeeeeeeeez help thank you
marmoora
 
Posts: 1
Joined: Sat May 01, 2010 2:05 am



Who is online

Users browsing this forum: No registered users and 4 guests