# Thread: Practice Problems Help

1. ## Practice Problems Help

I'm reading through "Jumping into C++" and doing the practice problems. After the chapter on switches and enums one of the practice problems is to create a tic tac toe game. I've looked all through the previous chapters but I can't find a way to build a game board with spaces that can be filled with an X or an O. I don't really understand the concept if an enumerate which may be my problem. I'm not asking for the solution, just where to look so that I have the knowledge to solve it myself. Thank you for your help!

2. Enumerated types are basically assigning a value to a "word" and you can use that word later on as a replacement for that value which helps readability. I know what the book wants you to do, and that is to create an enumerated type which contains X and O, and then check whether or not a board position contains either X or O, but the exercise is kinda weird and since it is a book for beginners, the prior chapters and the question doesnt give much information on how the complete program should look like.

I too had problems with that exercise, and you are gonna find some other exercises weird as well. Some chapters may sound very greek at times (atleast they did to me) and suddenly the type of exercises or the difficulty level completely change.

I started reading "Jumping into C++", but I switched to "C++ Primer 5th edition" instead. Exercises like the one you mentioned made me switch and the fact that "C++ Primer" is much more detailed and they introduce you to (in my very unprofessional opinion) programming concepts and general programming a lot easier and better. I kinda suggest you to switch to another book as well(I recommend C++ Primer).

3. C++ Primer which you mention is a very good book. I'd recommend this, as well.

As for an enumeration, basically it creates a new type and the only "valid" values you can assign to a variable of that type is the ones mentioned inside the enumeration type.
To give a comparison, consider a ranged integer. Say you want a variable that can only hold numbers from 0 to 100. No other values are valid. Then you would theoretically create a new type where you tell the compiler: limit the valid values to these that I specify.
An enumeration is the same concept. It allows you to create a new type and tell the compiler that these values are the only valid values this variable can hold.

So for tic-tac-toe, you would create an enumeration that contains X and O. That tells the compiler that any variable of this enumeration type can only hold these two values. All other values are invalid.

Popular pages Recent additions