1 / 22

ITK 168 Decisions

ITK 168 Decisions. Dr. Doug Twitchell September 20, 2005. IF. What if I want the robot to pick a thing up if there’s one there, but not pick a thing up if there isn’t?. if. if(bob.canPickThing()){ bob.pickThing(); }. if(<<test>>){ <<list of statements>> }. if.

Download Presentation

ITK 168 Decisions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ITK 168 Decisions Dr. Doug Twitchell September 20, 2005

  2. IF • What if I want the robot to pick a thing up if there’s one there, but not pick a thing up if there isn’t?

  3. if if(bob.canPickThing()){ bob.pickThing(); } if(<<test>>){ <<list of statements>> }

  4. if if(bob.canPickThing()){ bob.pickThing(); } boolean statement if(<<test>>){ <<list of statements>> }

  5. if if(bob.canPickThing()){ bob.pickThing(); } true or false boolean statement if(<<test>>){ <<list of statements>> }

  6. if Flowchart

  7. if • Can I use this to see if there is a wall in front of me?

  8. if if(bob.frontIsClear()){ bob.move(); } bob.turnLeft(); bob.move(); <<previous statements>> if(<<test>>){ <<list of statements>> } <<continue with following>>

  9. if • What if I want it to left if the front isn’t clear?

  10. if if(!bob.frontIsClear()){ bob.turnLeft(); } bob.move(); <<previous statements>> if(<<test>>){ <<list of statements>> } <<continue with following>>

  11. if • Can I check to see if the robot is on a certain street?

  12. if == equal > greater than < less than >= g.t. or equal <= l.t. or equal != not equal if(bob.getStreet == 1){ bob.move(); } if(<<test>>){ <<list of statements>> }

  13. while • what if I want the robot to pick up all of the things in a row

  14. while while(bob.canPickThing()){ bob.pickThing(); bob.move(); } while(<<test>>){ <<list of statements>> }

  15. while while(bob.canPickThing()){ bob.pickThing(); bob.move } true or false boolean statement while(<<test>>){ <<list of statements>> }

  16. while Flowchart

  17. while • How about moving the robot until it gets to avenue 50?

  18. while while(bob.getAvenue() < 50){ bob.move } while(<<test>>){ <<list of statements>> }

  19. if…else • What about when want to turn right if wall is in front and turn left otherwise?

  20. if…else if(bob.frontIsClear()){ bob.turnLeft(); } else { bob.turnRight(); } bob.move(); true or false boolean statement if(<<test>>){ <<list of statements>> }

  21. if…else Flowchart

  22. Example • How can we change the street cleaning robots to make it work better with if and/or while statements?

More Related