This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TicTacToe in Java Applet

 
Yong Park
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
basically this is my end of the year project.
I do not have much knowledge in Java but I do have Perl and C++ programming background. I jumped right into this project started to test few things out and I am lost big time. The error message reads "illegal start of expression" and points to "public void paint". What am I doing wrong?
[ edited to format code a bit and to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ April 14, 2004: Message edited by: Dirk Schreckmann ]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Non Dairy,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!
 
Yong Park
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just changed it. I guess I should've looked at that "naming policy"! After I saw the forum guidelines and rules and regulations, I didn't feel the need to look at it.
hopefully someone can come up with an answer to my question.. I am digging through my books and constantly refreshing this post!! Also any suggestions on how to go about doing this applet will be appreciated(algorithms and useful native java packages).
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to object-oriented programming in Java.
Without spending the time to learn to program in Java, you're likely to have a hard time programming in Java.
Note that class is not a set of instructions that get sequentially executed when loaded into memory.
Follows is a modified version of your applet that will compile, run and do something. But this isn't really an example of something well-designed. Perhaps it'll give you an idea for getting started.

With an applet, getting user input through the console probably isn't a good idea, especially as many applet users don't have their console enabled and displayed. Something like a text field would be more appropriate.
Also, as in this ugly example, putting the program control logic in the paint method isn't a good idea. The paint method is for displaying something, not for controlling the flow of a program.
Here is a list of free on-line tutorials and books that I have found useful for learning about programming in Java:
  • Sun's Java Tutorial
  • Introduction to Computer Science using Java by Bradley Kjell
  • Introduction to Programming Using Java by David J. Eck
  • Dick Baldwin's Java Programming Tutorials
  • Interactive Programming In Java by Lynn Andrea Stein
  • Bruce Eckel's Thinking In Java
  • JavaRanch's own Campfire Stories
  • Allen B. Downey's How To Think Like A Computer Scientist
  • Good luck, and don't hesitate to post more questions around here.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic