Checkers

Hello guys,
Sorry to bother you all. I am making a program of checkers and it is in process. But in the stage of debugging, i couldnt understand the error that came.
Kindly , if possible, point me to the right direction.

I am checking whether the coordinates entered by the player are the right location or not.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

class piece{
	
public:
string boardd[16][16];
void board ()
 {
 	
   
	
	
	boardd [0][1]='W';
	boardd [0][3]='W';
	boardd [0][5]='W';
	boardd [0][7]='W';
	boardd [1][0]='W';
	boardd [1][2]='W';
	boardd [1][4]='W';
	boardd [1][6]='W';
	boardd [2][1]='W';
	boardd [2][3]='W';
	boardd [2][5]='W';
	boardd [2][7]='W';
	
	boardd [5][0]='B';
	boardd [5][2]='B';
	boardd [5][4]='B';
	boardd [5][6]='B';
	boardd [6][1]='B';
	boardd [6][3]='B';
	boardd [6][5]='B';
	boardd [6][7]='B';
	boardd [7][0]='B';
	boardd [7][2]='B';
	boardd [7][4]='B';
	boardd [7][6]='B';
	
	cout<<"1\t2\t3\t4\t5\t6\t7\t8"<<endl<<endl;
	
	for(int x=0;x<8;x++)
	{
	
			
		for(int y=0;y<16;y++)
		{
		cout<<boardd[x][y];
		 cout<<"\t";
		}
		cout<<"\t\t"<<x<<endl;
		
		
	}
}
	
void takemove()
{
	cout<<"\nEnter the y coordinate of the peice\n";
	cin>>locationy;
	board();
	cout<<"\nEnter the x coordinate of the piece\n";
	cin>>locationx;
	board();
	cout<<"\nEnter the y coordinate you want to move\n";
	cin>>gotooy;
	board();
	cout<<"Enter the x coordinate you want to move\n";
	cin>>gotoox;
	board();
	
	{
if 	(boardd[locationy][locationx] == 'W' || 'B')
{

	cout<<"sucess";}
	
	else {
		cout<<"fail";
	}
	
}
	
}

// void validate()


private: 
   int locationx;
   int locationy;
   int gotoox;
   int gotooy; 
   
	

	
};

using namespace std;
int main()
{
	
	piece peece;
	peece.board();
	peece.takemove();
	
	
	
	return 0;
	
	
	
}
I am getting error at line 75
line 75: C++ does not support implied left hand side in conditionals. You must fully specify the conditions.

Example:
if (ans == 'Y' || 'y') evaluates as if (ans == ('Y' || 'y'))

('Y' || 'y') evaluates to 1 (true), before being compared to ans.

Line 9: A string is somewhat overkill for a square on the board, but that does eliminate the initialization problem. However, your board is going to print funny. Because board is an array of strings, and empty squares are null strings, those squares will not print a space, but rather nothing. This will screw up the alignment of your board. I would tend to use char board[8][8] for the board, but that requires initializing every location.

Line 9: Not clear why you've dimensioned the board as 16x16.

Last edited on
Thanks alot, that minor thing got me a headache.
Topic archived. No new replies allowed.