Results 1 to 5 of 5

Thread: Compile Issue

  1. #1
    Join Date
    May 2008
    Posts
    9
    Rep Power
    0

    Default 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());"

    Java 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

  2. #2
    rjuyal's Avatar
    rjuyal is offline Senior Member
    Join Date
    Mar 2008
    Location
    Delhi, India
    Posts
    194
    Rep Power
    7

    Default

    1st thing:

    Java 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

  3. #3
    Join Date
    May 2008
    Posts
    9
    Rep Power
    0

    Default

    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

  4. #4
    rjuyal's Avatar
    rjuyal is offline Senior Member
    Join Date
    Mar 2008
    Location
    Delhi, India
    Posts
    194
    Rep Power
    7

    Default

    D:D
    whatever it is, but at the end, the game is i like the way you write :cool:
    i am the future

  5. #5
    Join Date
    May 2008
    Posts
    9
    Rep Power
    0

    Default

    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

Similar Threads

  1. doesn't compile?!
    By jon80 in forum New To Java
    Replies: 8
    Last Post: 06-14-2008, 05:42 PM
  2. JFormattedTextField Issue
    By teracomp in forum AWT / Swing
    Replies: 1
    Last Post: 01-21-2008, 06:55 PM
  3. Not able to compile
    By bugger in forum New To Java
    Replies: 2
    Last Post: 01-09-2008, 10:13 PM
  4. Issue
    By chaitu444 in forum New To Java
    Replies: 2
    Last Post: 11-06-2007, 07:49 PM
  5. compilation issue
    By orchid in forum Eclipse
    Replies: 2
    Last Post: 04-20-2007, 12:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •