first quick java program

  • From: "Littlefield, Tyler" <tyler@xxxxxxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Tue, 22 Mar 2011 11:54:37 -0600

Hello all:
I am writing a quick tic-tac-toe game, and so far I have Java printing out the board. I'm curious if 1) this is the right way to go about it, and 2), i'm noticing that I have to declare PrintBoard as static. Is there a way around that?
Thanks,
public class ttt
{
public static void PrintBoard(String[] board)
{
int i, j;
System.out.println("|-|-|-|");
for (i= 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
System.out.print(board[i*j]+"|");
}
System.out.println("|-|-|-|");
}
}

public static void main(String[] args)
{
int i;
String[] board = new String[9];
for (i = 0; i < 8; i++)
{
board[i] = " ";
}
PrintBoard(board);
}

}

--

Thanks,
Ty

__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: