top of page

(Solved) Tic-Tac-Toe game with n x n  size in Java Solution is available.

Northeastern Illinois University CS304, Data Structures, Summer 2020
Homework 1
Due date: Wednesday 5/27/2020 by 11:59 p.m.
Problem 1:
In this problem you are required to create a Tic-Tac-Toe game that can have
different sizes. The size of the game will be entered by the user; you can assume
it’s greater than 2.
Complete the TicTacToe class I provided in the needed files, the class contains all
the constructor and method headers that you need to complete. You can add any
methods you think you might need.
- You can define as many as instance variables you want.
- initializeGrid() sets every cell of the grid to a hyphen “-“.
- setPlayer() sets which player is playing next.
- getPosition() should prompt the user for cell row and column, the method
checks if the row and column entered by the user are valid values. If the
user enters invalid row and column or of a cell that’s already taken, the
method keeps prompting until a set of a valid row and column are entered.
- isOccupied() checks if the cell is already taken.
- isFull() checks if the grid is full(all cells contain X’s or O’s).
- winner() checks if there is a winner in the game. The method should check
for a winner in vertical, horizontal and diagonal (minor and major) lines.
- toString() returns a String that contains the grid with the proper line brakes,
so printing the returned String should display the grid in the following
format:
- play() This method should have a sequence of call statements to the other
methods in the TicTacToe class to manage the game.
- If the grid is full and there is no winner, the program should display “It’s a
tie”.
- If there is a winner, the method should display “player is a winner”, where
the word player is replaced with winner’s name.
- The TicTacToeApp.java is already provided to you, the class contains the
main method and should be used as a testing application for
TicTacToe.java.
- - X -
- - - -
- - - X
- O - -
General Instructions:
- No hard copies will be collected.
- Do not send your files through the email!
- You should submit your work by the due date, No extensions will be given.
(See syllabus for late homework policy).
- DO NOT turn in multiple files, only one .zip file.
What to turn in:
There should be one .java files(TicTacToe.java), put the file into a zip file and
name it <YourFirstName_YourLastName>.zip, submit the zip file into the
Dropbox on D2L.
How to zip multiple files?
On Windows: Select all the files > right click > Send to > Comprised File
On Mac: Select all the files > Click/Tap with two fingers > Compress Items

(Solved)Northeastern Illinois University CS304, Data Structures,TicTacToe.java

$100.00 Regular Price
$95.00Sale Price
    bottom of page