Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TicTacToe1D{
- //Declare and initialize a static String array with 9 spots. Name it board.
- //Write a static method named initBoard to initialize all elements in board to spaces.
- //The method receives no parameters and returns nothing.
- //Write a static method named displayBoard to print out the board in TicTacToe board style
- //The method receives no parameters and returns nothing.
- //Ex:
- // X| |O
- // -+-+-
- // O|X|O
- // -+-+-
- // X|O|X
- //Write a static method to do a move and name it move
- //The method takes in a String representing the player (O/X)
- //The method takes in an int representing the spot
- //The method returns true if valid move (legal index and currently occupied by space) and puts the move in the board at index spot, false otherwise
- //Write a method called diagWin to check diagonals for win - return true if there is a winner, false otherwise
- //The method receives no parameters
- //Write a method called vertWin to check verticals for win - return true if there is a winner, false otherwise
- //The method receives no parameters
- //Write a method called horizWin to check horizontals for win - return true if there is a winner, false otherwise
- //The method receives no parameters
- //Write a method called checkWin - if diagWin or vertWin or horizWin is true, return true, false otherwise
- //The method receives no parameters
- //Write a main method to play the game.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement