This site requires JavaScript, please enable it in your browser!
Greenfoot back
RM6442
RM6442 wrote ...

2012/4/22

If One Statement is True

RM6442 RM6442

2012/4/22

#
I want to know if there is a way to write an if statement with several possible conditions, and only one needs to be true in order to continue.
RM6442 RM6442

2012/4/22

#
Sorry, but I don't mean something like
if( (isLeft)||(isRed) )
my code goes like this:
public boolean canDown()
    {
        Actor stop = getOneIntersectingObject(CornerDR.class);
        if (stop==null)
        {
            stop = getOneIntersectingObject(CornerDL.class);
        }
        return stop !=null;
    }
I want to do this for several classes
RM6442 RM6442

2012/4/22

#
Never mind, I took a closer look at my code and found that this works
Boolean tr= false;
        if ((getOneIntersectingObject(CornerDR.class)!=null)||(getOneIntersectingObject(CornerDL.class)!=null))
        {
            tr=true;
        }
        return tr;
You need to login to post a reply.