Jump to content

Expression errors making no sense!?


Rigged089

Recommended Posts

I've spent ages writing my first script in java but for nearly all my methods I get these errors (example):

 

C:\Users\xxx\Documents\JCreator Pro\MyProjects\1main.java:107: error: illegal start of expression
public void deposit() //throws InterruptedException
       ^
C:\Users\xxx\Documents\JCreator Pro\MyProjects\1\main.java:107: error: ';' expected
public void deposit() //throws InterruptedException
 
 
the start of this method is what is causing the errors as well as the other methods in the class.
public void deposit() throws InterruptedException
{
	Entity bank1 = objects.closest("Bank booth");
	if (bank1 != null)
	{
		while(!this.bank.isOpen())
		{
		bank1.interact("Bank");
		sleep(random(100, 220));
		}	
		if (this.bank.isOpen())
		{
			this.bank.depositAllExcept(995);
			sleep(random(50, 160));	
			this.bank.withdrawAll(xxxx);
			sleep(random(50, 160));	
		}
	}
}

It just doesn't make any sense and I can't find the issue... 

 

Moreover, will this deposit method successfully deposit and withdraw? 

 

Any advice is highly appreciated thank you!

 

Link to comment
Share on other sites

ew!

 

Don't use while loops :)

 

here: I rewrote it a bit:

public void deposit() throws InterruptedException
{
	Entity bank1 = objects.closest("Bank booth");
	if (bank1 != null && bank1.exists())
	{
		if(!this.bank.isOpen())
		{
		bank1.interact("Bank");
		sleep(random(1000, 2200));
		} else {
                        this.bank.depositAllExcept(995); //USE NAMES! MUCH EASIER TO READ
			sleep(random(50, 160));	
			this.bank.withdrawAll(xxxx); //you have xxxx here, not sure if you intended for this
			sleep(random(50, 160));	
                }	
	}
}

That should work successfully.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...