Docsity

Tic-Tac-Toe Program Development for Two Players, Assignments of Computer Science

Toggle sidebar
bg1
COP 3223 Make Up Program #5
Write a program that allows two users to play tic-tac-toe against each other. Your
program should allow each user to either the row and column of their move, and make
sure that valid values are entered. Also, if there is a winner, your program should print
out a message to that effect right after the winning move. If the game is a cats game, your
program should print a message out to that effect after the board is filled. Here is a
sample run:
Player #1(X) enter your move, row followed by column:
0 1 2
0 _ _ _
1 _ _ _
2 _ _ _
1 1
Player #2(O) enter your move, row followed by column:
0 1 2
0 _ _ _
1 _ X _
2 _ _ _
1 1
Sorry, that is not a valid move. Try again.
0 0
Player #1(X) enter your move, row followed by column:
0 1 2
0 O _ _
1 _ X _
2 _ _ _
2 2
Player #2(O) enter your move, row followed by column:
0 1 2
0 O _ _
1 _ X _
2 _ _ X
pf2

Partial preview of the text

Download Tic-Tac-Toe Program Development for Two Players and more Assignments Computer Science in PDF only on Docsity!

COP 3223 Make Up Program # Write a program that allows two users to play tic-tac-toe against each other. Your program should allow each user to either the row and column of their move, and make sure that valid values are entered. Also, if there is a winner, your program should print out a message to that effect right after the winning move. If the game is a cats game, your program should print a message out to that effect after the board is filled. Here is a sample run: Player #1(X) enter your move, row followed by column: 0 1 2 0 _ _ _ 1 _ _ _ 2 _ _ _ 1 1 Player #2(O) enter your move, row followed by column: 0 1 2 0 _ _ _ 1 _ X _ 2 _ _ _ 1 1 Sorry, that is not a valid move. Try again. 0 0 Player #1(X) enter your move, row followed by column: 0 1 2 0 O _ _ 1 _ X _ 2 _ _ _ 2 2 Player #2(O) enter your move, row followed by column: 0 1 2 0 O _ _ 1 _ X _ 2 _ _ X

Player #1(X) enter your move, row followed by column: 0 1 2 0 O _ _ 1 O X _ 2 _ _ X 2 0 Player #2(O) enter your move, row followed by column: 0 1 2 0 O _ _ 1 O X _ 2 X _ X 0 2 Player #1(X) enter your move, row followed by column: 0 1 2 0 O _ O 1 O X _ 2 X _ X 2 1 Player #1 wins! Here is the final game board: 0 1 2 0 O _ O 1 O X _ 2 X X X