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

  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.

  Create and implement class called date to store month

Create and Implement the class called Date which has data members to store month (as a number), day, year, and name of month.

  Class named person with fields for holding a person''s name

Design a class named Person with fields for holding a person's name, address, and telephone number. Write one or more constructors and the appropriate mutator and accessor methods for the class's fields.

  Palindrome is a sequence of char that reads backward forwrd

A palindrome is a sequence of characters that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554, and 11611. Write an application called Palindrome.java that asks the user t..

  Presell a limited number of cinema tickets

Write an application to presell a limited number of cinema tickets. each buyer can buy as many as 4 tickets. No more than 100 tickets can be sold. Implement a program called TicketSeller that prompts the user for the desired number of tickets and the..

  Write a program to read a file and encode

Write a program to read a file and encode the file to an encrypted file. And write a program to get an encrypted file and decode to original file. Your program should prompt the user to enter an input file name and an output file name

  Write an application that extends jframe

Write an application that extends JFrame and that displays a phrase in every font size from 6 through 20.

  Method that accepts a string object

Word Counter Write a method that accepts a String object as an argument and returns the number of words it contains. For instance, if the argument is "Four score and seven years ago" the method should return the number

  Write a program that prompts the user for a start date

write a program that prompts the user for a start date and an end date and then prints all of the dates between them (inclusive), with seven tab-separated dates on each line.

  Write a program in java that simulates a simple line editor

Write a program in Java that simulates a simple line editor which supports the following operations

  Java-s ability to derive new fonts from existing ones

Find out where on your system these font libraries are located. When you do, please specify the operating system and the location (folder/directory) where you found them. Discuss Java's ability to derive new fonts from existing ones.

  Produces a simple formatted report

For this lab you will write a Java program that produces a simple formatted report. The program will prompt the user to enter a file name. This file must contain information in a specific format (detailed below)

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