Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-14-2008, 05:43 PM
Member
 
Join Date: May 2008
Posts: 9
CrazyShells Slam is on a distinguished road
Compile Issue
Im having a compiler issue. It keeps asking for a ';' but I have all of them accounted for as far as I know, and I have all the brackets arranged nicely and such and I still cannot see the problem. Heres my code, if I posted the code wrong I apologize.

also I should note before I forget...the specific problem lies in the Run method, and points to the line "for (control.gameOver());"

Code:
import java.net.*; import java.io.*; public class Player extends Thread { private Socket connection; private DataInputStream input; private DataOutputStream output; private TicTacToeServer control; private int number; private char mark; protected boolean threadSuspended = true; public Player(Socket s, TicTacToeServer t, int num) { mark = (num == 0 ? 'X' : 'O'); connection = s; try { input = new DataInputStream (connection.getInputStream()); output = new DataOutputStream (connection.getOutputStream()); }/*end try*/ catch (IOException e) { e.printStackTrace(); System.exit(1); }//end catch control = t; number = num; }//end Player public void otherPlayerMoved(int loc) { try { output.writeUTF("Opponent moved"); output.writeInt(loc); }/*end try*/ catch (IOException e) {e.printStackTrace(); }//end catch }//end otherPlayMoved public void run() { int done = false; try { control.display("Player" + (number ==0 ? 'X' : 'O') + "Connected"); output.writeChar(mark); output.writeUTF("Player" + (number == 0? "X connected\n" : "O connecteded\n")); if(mark == 'X') { output.writeUTF("Waiting for another opponent..."); try { synchronized(this) { while(threadSuspended) wait(); }//end synch }/*end try*/ catch(InterruptedException e) { e.printStackTrace(); }//end catch output.writeUTF("Other player connected....time to play the game"); }//end IF while(!done) { int location = input.readInt(); if(control.validMove(location, number)) { control.display("loc" + location); output.writeUTF("Valid move"); }//end if else output.writeUTF("nope"); for (control.gameOver()); done = true; }//end while connection.close(); }/*end try*/ catch (IOException e) { e.printStackTrace(); System.exit(1); }//end catch }//end Run }//end Player class
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-14-2008, 07:02 PM
rjuyal's Avatar
Senior Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 187
rjuyal is on a distinguished road
1st thing:

Code:
public void run() { int done = false;

you cannot assign boolean value to integer.



2nd:
you need to post the code of TicTacToeServer
__________________
i am the future
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-14-2008, 10:23 PM
Member
 
Join Date: May 2008
Posts: 9
CrazyShells Slam is on a distinguished road
I had changed it...oh well I mustve posted it before I saved it? Cuz I had a copy on my flash and on the desktop. Hold on, if need be Il post the server class also
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-14-2008, 10:29 PM
rjuyal's Avatar
Senior Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 187
rjuyal is on a distinguished road

whatever it is, but at the end, the game is i like the way you write
__________________
i am the future
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-14-2008, 10:51 PM
Member
 
Join Date: May 2008
Posts: 9
CrazyShells Slam is on a distinguished road
Alright so IM doing some tinkering with it, correcting it all. Yeah I had posted the saved version of that file -_- lol. So in my efforts to convert the necessary parameters and what not to ints I have come across an illegal start of expression error. What u posted before about the whole boolean and int conflict. How would I change that so the variable returns an int, cuz obv IM doing it wrong for some reason....lol
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
doesn't compile?! jon80 New To Java 8 06-14-2008 07:42 PM
JFormattedTextField Issue teracomp AWT / Swing 1 01-21-2008 08:55 PM
Not able to compile bugger New To Java 2 01-10-2008 12:13 AM
Issue chaitu444 New To Java 2 11-06-2007 09:49 PM
compilation issue orchid Eclipse 2 04-20-2007 02:51 AM


All times are GMT +3. The time now is 04:21 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org