Results 1 to 2 of 2

Thread: illegal start sxpression

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2007
    Posts
    39

    illegal start sxpression

    Hi could anyone help me tell what is wrong with this code which produce error illegal start sxpression, I know that missing bracket before the the second sychnorized method but if add a bracket,it produce alot of error which is not actual error. Thanks alot

    Code:
    import java.awt.*;
    public class AppletTest extends java.applet.Applet
    {
    	
    	private Hare hare;
    	private Tortoise torties;
    	private Image harePic, tortoisePic;
    	private final int HARE_TURN = 0;
    	private final int TORT_TURN = 0;
    	private int turn = 0;
    	private int sleepTime = 200;
    	
    	public void init()
    	{
    		hare = new Hare();
    		torties = new Tortoise();
    		harePic = new Image("");
    		tortoisePic = new Image("");
    			
    	}
    	
    	public void paint(Graphics g)
    	{
    		g.drawImage(harePic,hare.getPosition(),40,this);
    		
    		g.drawImage(tortoisePic,tortoise.getPosition(),100,this);
    		
    		
    	
    	}
    	
    	public synchronized void HareAdvance()
    	{
    		while(turn == HARE_TURN)
    		{
    				try{
    					wait();
    		}catch(InterruptedException e )
    		{}
    			repaint();
    		
    		try
    		{
    			Thread.sleep(sleepTime);
    		}catch(InterruptedException e )	
    		{}
    		
    		turn = TORT_TURN -	turn;
    	}
    	
    	
    	public synchronized void  TortoiseAdvance()
    	{
    		
    			while(turn != HARE_TURN )
    			{
    				try{
    					wait();
    				}catch(InterruptedException e )
    				{}
    			}
    			repaint();
    			try
    			{
    				Thread.sleep(sleepTime);
    			}catch(InterruptedException e )
    				{}
    			
    
    	
    	turn = TORT_TURN -	turn;
    	
    	}
    	
    }

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: illegal start sxpression

    Because you forgot to close the HareAdvance method, Just add the curly barcket } to the end of that method
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

Posting Permissions

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



Click Here to Expand Forum to Full Width