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

2015/11/13

Is there an "OR" thing in greenfoot

Elexios Elexios

2015/11/13

#
is there something in greenfoot like an "or" what i want to do is check if this class is not touching any of the listed classes and if not do something else, the something else should not be able to happen if it is touching any of the classes not all.
 if (isTouching(Skyscraper.class))
          if (isTouching(RoadSide.class))
          if (isTouching(RoadTurn1.class))
          if (isTouching(RoadTurn2.class))
          if (isTouching(RoadTurn3.class))
          if (isTouching(RoadTurn4.class))
          if (isTouching(House.class))
          if (isTouching(Tree.class))
          if (isTouching(Rail.class))
          if (isTouching(RailSide.class))
          if (isTouching(Factory.class))
          if (isTouching(Hospital.class)) 
          
          
          if (Greenfoot.isKeyDown("enter"))  
          {getWorld().addObject(new Road (),x,y);   
          getWorld().removeObject(this); 
         } else
          
         if (Greenfoot.isKeyDown("escape"))
          getWorld().removeObject(this);
any help? :)
danpost danpost

2015/11/13

#
Elexios wrote...
is there something in greenfoot like an "or"
See the middle section of the linked page, with the header Conditional Operators, in the java tutorials.
You need to login to post a reply.