Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Tic-Tac-Toe
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
.:hacker:.




PostPosted: 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 Very Happy

Edit: BTW It's for two human players, not human VS CPU.



javaTicTac.doc
 Description:
The full thing

Download
 Filename:  javaTicTac.doc
 Filesize:  24.5 KB
 Downloaded:  277 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
JackTruong




PostPosted: 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




PostPosted: Mon May 09, 2005 6:56 pm   Post subject: (No subject)

A note. This:

code:
printRow (0,grid);


Should be:

code:
printRow(0, grid);


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




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: