Tic-Tac-Toe
Author |
Message |
.:hacker:.
|
Posted: Mon May 09, 2005 4:42 pm Post subject: Tic-Tac-Toe |
|
|
Hey all,
I've been doing a text based tic-tac program recently and naturally I come across a couple of problems. First and foremost is the syntax error that never disappears:
public static void printGrid(String [] grid)
{
printRow (0,grid); // Print first row
printDivider (); // Print grid line
printRow (3,grid); // Print second row
printDivider (); // Print grid line
printRow (6,grid); // Print last row
}
Its says printRow doesn't exist, but how is that? My teacher had a sheet and I wrote the printRow lines exactly how he had it. Until I fix the grid problem, I don't even know how O or X will input moves or how to check wins, losses, and draws. Th easy stuff like restarting has already been done. If anyone has any suggestions for me, that would be appreciated. Oh, and the code has been put for reference
Edit: BTW It's for two human players, not human VS CPU.
Description: |
|
Download |
Filename: |
javaTicTac.doc |
Filesize: |
24.5 KB |
Downloaded: |
288 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
JackTruong
|
Posted: Mon May 09, 2005 5:56 pm Post subject: (No subject) |
|
|
Why would PrintRow be in it's own separate class? Easier just to make it within a method of the first class.
Heck.. Why is everything in a class?
The reason why it's giving you a syntax error (which isn't a syntax error) is because printRow() is in another class, and you'd have to make an instance of it before calling it.
My recommendation: Rid the classes, and try.
|
|
|
|
|
|
wtd
|
Posted: Mon May 09, 2005 6:56 pm Post subject: (No subject) |
|
|
A note. This:
Should be:
It's a style thing, but the latter is the correct style.
Oh, and why .doc? You should never write code in Word. Only use a plain text editor, like Notepad or Textpad on Windows.
|
|
|
|
|
|
wtd
|
Posted: Tue May 10, 2005 4:26 pm Post subject: (No subject) |
|
|
Having had a more thorough look, I would say that if your teacher wrote that, you need to find a new teacher. I appreciate that it can be difficult to stay on top of technological change, but that program ignores even basic, fundamental Java naming conventions.
|
|
|
|
|
|
|
|