pikau
pikau
CC#
Created by pikau on 3/29/2024 in #help
Defining and checking a 2D string array
have a good rest of your day :)
428 replies
CC#
Created by pikau on 3/29/2024 in #help
Defining and checking a 2D string array
thanks so much, i appreciate that immensely... i will let you know!
428 replies
CC#
Created by pikau on 3/29/2024 in #help
Defining and checking a 2D string array
thanks so much for your help over the past day, i am truly indebtted
428 replies
CC#
Created by pikau on 3/29/2024 in #help
Defining and checking a 2D string array
im all done now!
428 replies
CC#
Created by pikau on 3/29/2024 in #help
Defining and checking a 2D string array
alright the program passes all 18 possible combinations
428 replies
CC#
Created by pikau on 3/29/2024 in #help
Defining and checking a 2D string array
alright ill take your word for it
428 replies
CC#
Created by pikau on 3/29/2024 in #help
Defining and checking a 2D string array
hahaha
428 replies
CC#
Created by pikau on 3/29/2024 in #help
Defining and checking a 2D string array
i assume thats good/common practice too?
428 replies
CC#
Created by pikau on 3/29/2024 in #help
Defining and checking a 2D string array
ahhhh right
428 replies
CC#
Created by pikau on 3/29/2024 in #help
Defining and checking a 2D string array
your*
428 replies
CC#
Created by pikau on 3/29/2024 in #help
Defining and checking a 2D string array
ill do you way it looks a little nicer haha
428 replies
CC#
Created by pikau on 3/29/2024 in #help
Defining and checking a 2D string array
ive got two left diaongals for the OOO
428 replies
CC#
Created by pikau on 3/29/2024 in #help
Defining and checking a 2D string array
yeah haha
428 replies
CC#
Created by pikau on 3/29/2024 in #help
Defining and checking a 2D string array
its right in front of me
428 replies
CC#
Created by pikau on 3/29/2024 in #help
Defining and checking a 2D string array
oh wait omg
428 replies
CC#
Created by pikau on 3/29/2024 in #help
Defining and checking a 2D string array
perhaps the logic is off ehre?
428 replies
CC#
Created by pikau on 3/29/2024 in #help
Defining and checking a 2D string array
public bool HasWinner()
{
// Create a for loop that checks if there is a row, column, or diagonal
// that contains 3 of the same input (e.g. someone has won). Usin inbuilt functions
for(int i = 0; i < 3 ; i++)
{
if (Board.GetRow(i) == "XXX" || Board.GetRow(i) == "OOO")
return true;
if (Board.GetColumn(i) == "XXX" || Board.GetColumn(i) == "OOO")
return true;
}

string leftDiagonal = Board.GetDiagonal(true);
string rightDiagonal = Board.GetDiagonal(false);
if (leftDiagonal == "XXX" || leftDiagonal == "OOO")
return true;
if (rightDiagonal == "XXX" || leftDiagonal == "OOO")
return true;

else
return false;
}
public bool HasWinner()
{
// Create a for loop that checks if there is a row, column, or diagonal
// that contains 3 of the same input (e.g. someone has won). Usin inbuilt functions
for(int i = 0; i < 3 ; i++)
{
if (Board.GetRow(i) == "XXX" || Board.GetRow(i) == "OOO")
return true;
if (Board.GetColumn(i) == "XXX" || Board.GetColumn(i) == "OOO")
return true;
}

string leftDiagonal = Board.GetDiagonal(true);
string rightDiagonal = Board.GetDiagonal(false);
if (leftDiagonal == "XXX" || leftDiagonal == "OOO")
return true;
if (rightDiagonal == "XXX" || leftDiagonal == "OOO")
return true;

else
return false;
}
428 replies
CC#
Created by pikau on 3/29/2024 in #help
Defining and checking a 2D string array
thats the diagaonal thing once again
428 replies
CC#
Created by pikau on 3/29/2024 in #help
Defining and checking a 2D string array
public string GetDiagonal(bool topLeftToBottomRight)
{
string diagonalString = "";

if (topLeftToBottomRight)
{
for (int i = 0; i < board.GetLength(0); i++)
{
diagonalString += board[i, i];
}
}
else
{
for (int i=0; i < board.GetLength(0); i++)
{
diagonalString += board[i, board.GetLength(1) -1 -i];
}
}
return diagonalString;
}
public string GetDiagonal(bool topLeftToBottomRight)
{
string diagonalString = "";

if (topLeftToBottomRight)
{
for (int i = 0; i < board.GetLength(0); i++)
{
diagonalString += board[i, i];
}
}
else
{
for (int i=0; i < board.GetLength(0); i++)
{
diagonalString += board[i, board.GetLength(1) -1 -i];
}
}
return diagonalString;
}
428 replies
CC#
Created by pikau on 3/29/2024 in #help
Defining and checking a 2D string array
this is the only time it returns an incorrect response
428 replies