A game of tic-tac-toe

Assignment Help JAVA Programming
Reference no: EM13168064

A game of tic-tac-toe, two players (one the computer) take turns marking an available cell in a 3 X 3 grid (a two dimensional array) with their respective tokens (either and X or an O). When one player has placed three tokens in a horizontal, vertical, or diagonal row on the grid, the game is over and that player has won. A draw (no winner) occurs when all the cells on the grid have been filled with tokens and neither player has achieved a win. Create a program for playing tic-tac-toe as follows:

  1. The program prompts the first player to enter an X or an O token your choice, then the computer will chose a location randomly and enter an O or an X in an open space. Whenever a token is entered, the program refreshes the board and determines the status of the game (win, draw, or unfinished).
  2. To place a token, prompt the user to enter the row and column for the token. The program then checks to see if the spot is open. If it is that token is placed in the spot. If not it prompts the user to choose another spot.
  3. This is the only program that MUST BE DONE FROM THE COMMAND LINE NOT A GUI!!!
  4. The program should have 4 methods, a main, a method to generate a random number for the computer to play, a method to print, and a method to check to see if anyone has won.
  5. You must use a 3x3 two dimensional array.

6. A run of the game should look like this: run: @ | @ | @ -- | --- |-- @ | @ | @ --|---|-- @ | @ | @ X player enter your ROW 0 X player enter your COL 0 x | @ | @ -- | --- |-- @ | @ | @ --|--- |-- @ | @ | @ x | o | @ --|---|-- @ | @ | @ --|---|-- @ | @ | @ X player enter your ROW 0 X player enter your COL 1 o has selected 0, 1 already try again! X player enter your ROW 1 X player enter your COL 0 x | o | @ --|---|-- x | @ | @ --|---|-- @ | @ | @ x | o | o --|---|-- x | @ | @ --|---|-- @ | @ | @ X player enter your ROW 1 X player enter your COL 1 x | o | o --|---|-- x | x | @ --|---|-- @ | @ | @ x | o | o --|---|-- x | x | o --|---|-- @ | @ | @ X player enter your ROW 2 X player enter your COL 0 x | o | o --|---|-- x | x | o --|---|-- x | @ | @ x wins with 3 down the first column

Reference no: EM13168064

Questions Cloud

Write a program that reads in a text file and then computes : Write a program that reads in a text file and then computes and prints a table of letter frequencies. For example, if the file is the text of "A Tale of Two Cities", found in the file at data/tales.txt , the program will print
Initialized the array of words by an assignment statement. : modify the following program . The program from Lab 4 initialized the array of words by an assignment statement.
There are four conditions that are necessary : There are four conditions that are necessary for a deadlock to occur. Give an example to show that these conditions are not sufficient for a resource deadlock to occur. When are these conditions sufficient for a resource deadlock to occur? Explain..
Explain the net chemical equation : When a strong base is added to a solution of CuSO4, which is pale blue, a precipitate forms and the solution above the precipitate is colorless. The net chemical equation is Cu(2+)(aq) + 2OH(-)(aq) --> Cu(OH)2(s)
A game of tic-tac-toe : A game of tic-tac-toe, two players (one the computer) take turns marking an available cell in a 3 X 3 grid (a two dimensional array) with their respective tokens (either and X or an O). When one player has placed three tokens in a horizontal
Define the heat of combustion is transferred to the water : how many liters of C6H14(l) measured at 20 degC must be burned to provide enough heat to warm 26.9m^3 of water from 17.7 to 32.6degC .
Explain the flame in a torch used to cut metal : The flame in a torch used to cut metal is produced by burning acetylene (C2H2) in pure oxygen. Assuming the cumbustion of 1 mole of acetylene released 1251 kJ of energy
Phosphoric acid is a weak triprotic acid : Phosphoric acid is a weak triprotic acid with the formula H3PO4. If you have 50.0 mL of a 1.0 M solution of H3PO4, how many grams of NaOH (MM = 40.0g/mol) should you add to make a buffer with a pH of 7.00?
Two-way set associative with 32 kb capacity and 64 byte : 1. Assume a two-way set associative with 32 KB capacity and 64 bytes blocks. a. How many bits are needed to represent the index size?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd