another newbie question (switch...case)
I know this is messy but i can't figure out why it's falling through;
theBoard is a [3][3] int array.
in this case move is an int thats 1-9.
and player is either 1 or 0. (0 in this case, 1 is the computer).
So the problem is, if move=1, then it falls through without the return you see on case 1. But i don't understand, if move==1 then case 2: shouldn't work, right?
Code:
void Board::makeMove(int move, int player){
switch (move){
case 1:
if(player==ONE){
theBoard[0][0]=88;
}
else{
theBoard[0][0]=79;
}
this->drawBoard();
return;
cout << "xxxxxx";
case 2:
if(player==ONE){
theBoard[1][0]=88;
}
else{
theBoard[1][0]=79;
}
case 3:
if(player==ONE){
theBoard[2][0]=88;
}
else{
theBoard[2][0]=79;
}
case 4:
if(player==ONE){
theBoard[0][1]=88;
}
else{
theBoard[0][1]=79;
}
case 5:
if(player==ONE){
theBoard[1][1]=88;
}
else{
theBoard[1][1]=79;
}
case 6:
if(player==ONE){
theBoard[2][1]=88;
}
else{
theBoard[2][1]=79;
}
case 7:
if(player==ONE){
theBoard[0][2]=88;
}
else{
theBoard[0][2]=79;
}
case 8:
if(player==ONE){
theBoard[1][2]=88;
}
else{
theBoard[1][2]=79;
}
case 9:
if(player==ONE){
theBoard[2][2]=88;
}
else{
theBoard[2][2]=79;
}
}
}