banner



How To Draw A Tic Tac Toe Board In Java

#1 Guest_CodeMan*

Drawing a TicTacToe Board

Posted 16 February 2011 - 11:10 PM

I need help drawing a tick tack toe board using the char data type. I would like the board to exist set using 9 squares (1 starting in the lesser left). And then when I inquire the user to pick a foursquare, he/she enters an int i-9. I need to utilise a toString() method. Any help would be great.
vii, 8, nine
4, v, 6
1, 2, 3

public course TicTacToe {    /**       Constructs an empty board.    */    public TicTacToe()    {       char [] lath = new char[10];        // fill with spaces       for (int i = 0; i < 10; i++)          {            board[i] = ' ';          }    }        public String toString()    {     }            


Is This A Proficient Question/Topic? 0

#two WickedBetrayal User is offline

  • D.I.C Caput

Reputation: 0

  • View blog
  • Posts: 84
  • Joined: 16-Feb 11

Re: Cartoon a TicTacToe Board

Posted xvi February 2011 - 11:18 PM

Well, to start off, you need a 2 dimensional array.

char[][] board = new char[3][three];     for (int i=0;i<board.length;i++) {// you tin likewise apply 3 instead of board.length since y'all know the length will ever be 3       for (int j=0;j<board.length;j++) {         board[i][j] = ' ';       }     }            

I think that should practise it.

Also, delight give information about the question. Not simply "I need to use a toString() method".

My information should get you started.

This post has been edited past WickedBetrayal: 16 February 2011 - 11:24 PM

#3 pbl User is offline

Reputation: 8381

  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Cartoon a TicTacToe Board

Posted 17 February 2011 - 04:24 PM

char[][] board = new char[3][3]; char grand = '0';     for (int i=0;i<board.length;i++) {       for (int j=0;j<lath.length;j++) {         lath[i][j] = ++k;         System.out.print(" " + lath[i][j]);       }       Arrangement.out.println();     }            

:)

This mail has been edited by pbl: 17 Feb 2011 - 04:25 PM
Reason for edit:: missing )

Source: https://www.dreamincode.net/forums/topic/216724-drawing-a-tictactoe-board/

Posted by: rountreeandestalmoss.blogspot.com

0 Response to "How To Draw A Tic Tac Toe Board In Java"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel