id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

tmhscs@gmail.com arrays2d > array2D_ticTacToe
prev  |  next  |  chance

Given three 1D String arrays containing either X's, O's, or spaces, create a 2D String array from them and return a String of who has won the game of tic-tac-toe based on the current state of the board. You should either return "X's win!", "O's win!", or "Tie!" Start your solution out with the following code:

String[][] board = {row1, row2, row3};
Hint: if(board[0][0].equals("X") && board[0][1].equals("X") && board[0][2].equals("X")) would check if the top row of the board was all X's!

array2D_ticTacToe(["X", "X", "X"], [" ", " ", " "], [" ", " ", " "]) → "X's win!"
array2D_ticTacToe([" ", " ", " "], ["X", "X", "X"], [" ", " ", " "]) → "X's win!"
array2D_ticTacToe([" ", " ", " "], [" ", " ", " "], ["X", "X", "X"]) → "X's win!"

...Save, Compile, Run (ctrl-enter)

public String array2D_ticTacToe(String[] row1, String[] row2, String[] row3) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Post-solution available

Copyright Nick Parlante 2017 - privacy