Hi, I have to make a Tic Tae Toe game using Classes but I have no idea how to even start.
I set 3x3 2 dimentional array as private member variable. What should be public variables?

Here is the instruction i was given:

1. The game board will be created as an object in the main program.This class will include a 2 dimensional (3 x 3) array of chars.Each element in this array can either hold an X or an O. This class should also have an appropriate constructor, getters and setters, display function, as well as a reset function.This class must also have a function called continue that returns a false if the game is over (either a stalemate or a win) or a true if the game can continue.

Recommended Answers

All 7 Replies

Take it a step at a time. Create the class, output the board. When you can do that move on to the next step whatever you think that is.

You add information to the class as you discover you need it.

i did this game long ago... when i was in grade 8 but i did it in qbasic..you want me to search the source code....??
and for the c++...i will try to do it...

here is the class structure i made for ur game...
each place that is 9 position will be instances of the class board, and since each will have player id, xpos, and ypos i believe the game coding will be smooth....

class board{
private:
       int is_filled;
       int player;
       int x_pos;
       int y_pos;
public:
       board(){}
	 void make_board(int x,int y){

	is_filled=0;
	player=0;//0 is empty,1 is player 1, 2 is player 2
	x_pos=x;
	y_pos=y;
	}
	board(int is_filled_get,int player_id,int x_get,int y_get)
	{
		is_filled=1;
		player=player_id;
		x_pos=x_get;
		y_pos=y_get;
	}
	int check_filled(){
		if(is_filled==0) //0 is empty
		{
		 return 0;
		}
		else
		{
		 return 1;

		}
	}
	void display()
	{

	cout<<x_pos<<","<<y_pos<<"box is filled by player"<<player;
	}
	~board(){};
};

Um, you may want to read this and this.

We don't give code away, we guide to a solution and provide non-specific example code when necessary.

lol...oks! but thats wasn't the complete ans!....anyways thanks...nice forum....SNIP

i did this game long ago... when i was in grade 8 but i did it in qbasic..you want me to search the source code....??
and for the c++...i will try to do it...

No. Start like I said before. A piece at a time.

thank you everybody for all this help!
I kind of get the idea how to start now =]]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.