Jump to content

getState() with multiple if statements


Recommended Posts

Posted
private enum State{
		BANK,
		MAKE,
		GRANDEXCHANGE,
	}
	
	private State getState() {
		
		if(inventory.contains(227) && inventory.contains(HighestMarginHerbId))
			return State.MAKE;
		return State.BANK;
	}

First of all im a beginner in scripting and in java.

Im trying to make getState() return GRANDEXCHANGE when bank does not contain the item 227 and HighestMarginHerbId. But it keeps giving me errors. 

Posted (edited)
if(!getBank().contains(227) || !getBank.contains(HighestMarginHerbId)) {
  return State.GRANDEXCHANGE;
}

Put that into your getState() method.

If the bank does not contain any of the items with id 227 OR HighestMarginHerbId, it will return to state GRANDEXCHANGE.

Edited by Woody
Posted
1 hour ago, Woody said:

if(!getBank().contains(227) || !getBank.contains(HighestMarginHerbId)) {
  return State.GRANDEXCHANGE;
}

Put that into your getState() method.

If the bank does not contain any of the items with id 227 OR HighestMarginHerbId, it will return to state GRANDEXCHANGE.

Should be && instead of || for the result you describe

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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