0

Hi, I have been given a project to finish in school in 3 phases, the thing is I am not that good when it comes to programing. The project was to develope a tic tac toe game as following:

**Phase 1:
Write a program that will first ask the user to choose their character ‘x’ or ‘o’, as follows:
Enter your favourite character ‘x’ or ‘o’: x
Then, the program should display the following tic-tac-toe board on the screen:

| 1 | 2 | 3 |

| 4 | 5 | 6 |

| 7 | 8 | 9 |

Next, ask the user to enter his/her selection, and based on the input, the program displays the
following output:
Enter your selection: 5

| 1 | 2 | 3 |

| 4 | x | 6 |

| 7 | 8 | 9 |

If the user selects a space that is already occupied by a symbol ( ‘o’ or ‘x’), the program
should display an error message such as, “The selected position is already taken”.
The program should terminate after five selections are made.**

This is my first programming class and I am already facing diffuclty in such a simple task. I have basic knowledge of if statemets and loops. But can't really understand bool and "void".
I keep seeing other posts mentioning "arrays & char board[3][3]". I don't really know what that is. is there any other ways to make a tic tac toe without that?

While writing a code would be nice, I am more willing to learn, as such, an explanation of how you wrote the code would be even better!

I am using visual c++ if that amounts to anything.

Edited by Khalid_12

4
Contributors
3
Replies
25
Views
4 Weeks
Discussion Span
Last Post by Sinisa_1
0

What you shown here is an array, with 9 elements.
(You can make array with ten "drawers" (from 0 to 9), and use from 1st to 9th.)

Array can contain digits (I didn't say "numbers"), from 1 to 9 in those places.
When you select position 5, check if there is digit, not X or O.
(If select position 3, before putting "X" or "O", check if it's "3" in there.)

So, array can't contain numbers, because X and O aren't numbers, and they have to go in.
What it can contain then?

Edited by Sinisa_1

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.