public class ConnectFour
{
public static bool check(string[][] myField, int a, int b)
{
string player = myField[a][b];
int vertical = 1;
int horizontal = 1;
int diagonal1 = 1;
int diagonal2 = 1;
int i;//vertical
int ii;//horizontal
//check for vertical(|)
i = a + 1;
while(i<=5)//Check up
{
if(i == a + 1 && myField[i][b] != player) break;
if(myField[i][b] == player) vertical++;
i++;
}
i = a - 1;
while(i >= 0)//Check down
{
if(i == a - 1 && myField[i][b] != player) break;
if(myField[i][b] == player) vertical++;
i--;
}
if(vertical >= 4)return true;
//check for horizontal(-)
ii = b - 1;
while(ii>=0) //Check left
{
if(ii == b - 1 && myField[a][ii] != player) break;
if(myField[a][ii] == player) horizontal++;
ii--;
}
ii = b + 1;
while(ii <=6) //Check right
{
if(ii == b + 1 && myField[a][ii] != player) break;
if(myField[a][ii] == player) horizontal++;
ii++;
}
if(horizontal >= 4) return true;
//check for diagonal 1 (\)
i = a - 1;
ii = b - 1;
while(i>=0 && ii >=0) //up and left
{
if(i == a - 1 && ii == b - 1 && myField[i][ii] != player) break;
if(myField[i][ii] == player) diagonal1++;
i--;
ii--;
}
i = a + 1;
ii = b + 1;
while(i<=5 && ii <=6) //down and right
{
if(i == a + 1 && ii == b + 1 && myField[i][ii] != player) break;
if(myField[i][ii] == player) diagonal1++;
i++;
ii++;
}
if(diagonal1 >= 4) return true;
//check for diagonal 2(/)
i = a - 1;
ii = b + 1;
while(i>=0 && ii <= 6) //up and right
{
if(i == a - 1 && ii == b + 1 && myField[i][ii] != player) break;
if(myField[i][ii] == player) diagonal2++;
i--;
ii++;
}
i = a + 1;
ii = b - 1;
while(i<=5 && ii >=0) //up and left
{
if(i == a + 1 && ii == b - 1 && myField[i][ii] != player) break;
if(myField[i][ii] == player) diagonal2++;
i++;
ii--;
}
if(diagonal2 >= 4) return true;
return false;
}
public static string WhoIsWinner(List<string> piecesPositionList)
{
int a1 = 0;
int b1 = 0;
int c1 = 0;
int d1 = 0;
int e1 = 0;
int f1 = 0;
int g1 = 0;
string temp = "";
string result = "";
string[][] myField = new string[6][];
for(int i = 0; i < 6; i++) myField[i] = new string[7];
for(int i = 0; i < piecesPositionList.Count; i++)
{
temp = piecesPositionList[i];
if(temp[0] == 'A')
{
myField[a1][0] = temp.Substring(2);
if(check(myField, a1, 0)) return temp.Substring(2);
++a1;
}
if(temp[0] == 'B')
{
myField[b1][1] = temp.Substring(2);
if(check(myField, b1, 1)) return temp.Substring(2);
++b1;
}
if(temp[0] == 'C')
{
myField[c1][2] = temp.Substring(2);
if(check(myField, c1, 2)) return temp.Substring(2);
++c1;
}
if(temp[0] == 'D')
{
myField[d1][3] = temp.Substring(2);
if(check(myField, d1, 3)) return temp.Substring(2);
++d1;
}
if(temp[0] == 'E')
{
myField[e1][4] = temp.Substring(2);
if(check(myField, e1, 4)) return temp.Substring(2);
++e1;
}
if(temp[0] == 'F')
{
myField[f1][5] = temp.Substring(2);
if(check(myField, f1, 5)) return temp.Substring(2);
++f1;
}
if(temp[0] == 'G')
{
myField[g1][6] = temp.Substring(2);
if(check(myField, g1, 6)) return temp.Substring(2);
++g1;
}
}
return "Draw";
}
}
Не пытался вникнуть в то что вы делаете там, но вот вам скрин с ошибками.
P.S. ConnectFour это название вашего класса зачем вы его вставили в вопрос ?
Есть xml файл с множеством элеменотовСтроки выглядят так:
В приложении при изначальном запуске - отсутствуют иконкиОднако в ресурсах соответствующие Image с заданными ключами присутствуют