public SetUp() { // Start -- menu theBoard = new BoardGame(); theDisplay = new Display(theBoard); Console.WriteLine("Enter player one's name"); String player1 = Console.ReadLine(); Console.WriteLine("Enter player two's name"); String player2 = Console.ReadLine(); thePlayers = new Players(player1, player2); checkWin = new CheckWinner(); theOption = new NewGame(); }
public Display(BoardGame theBoard) { board = theBoard; }
// Contains the logic to check who won the game public CurrentStateOnBoard CheckForWinner(int position, BoardGame board) { switch (position) { case 1: if (CheckTopRow(board) || CheckLeftColumn(board) || CheckLtRDiagonal(board)) { return(board.GetPositionState(1)); } break; case 2: if (CheckTopRow(board) || CheckMiddleColumn(board)) { return(board.GetPositionState(2)); } break; case 3: if (CheckTopRow(board) || CheckRightColumn(board) || CheckRtLDiagonal(board)) { return(board.GetPositionState(3)); } break; case 4: if (CheckMiddleRow(board) || CheckLeftColumn(board)) { return(board.GetPositionState(4)); } break; case 5: if (CheckMiddleRow(board) || CheckMiddleColumn(board) || CheckLtRDiagonal(board) || CheckRtLDiagonal(board)) { return(board.GetPositionState(5)); } break; case 6: if (CheckMiddleRow(board) || CheckRightColumn(board)) { return(board.GetPositionState(6)); } break; case 7: if (CheckBottomRow(board) || CheckLeftColumn(board) || CheckRtLDiagonal(board)) { return(board.GetPositionState(7)); } break; case 8: if (CheckBottomRow(board) || CheckMiddleColumn(board)) { return(board.GetPositionState(8)); } break; case 9: if (CheckBottomRow(board) || CheckRightColumn(board) || CheckLtRDiagonal(board)) { return(board.GetPositionState(9)); } break; default: return(CurrentStateOnBoard.Empty); } return(CurrentStateOnBoard.Empty); }