1 / 10

Functions and Methods for Returning Values

Learn about functions and methods that return different types of values such as number, boolean, and objects. Understand how these functions work and when to use them. Explore built-in functions for checking conditions, getting information about objects, and using proximity and spatial relationships. Create your own functions to add custom behavior to your programs.

marciar
Télécharger la présentation

Functions and Methods for Returning Values

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. Functions

  2. Functions • Methods that return a Value • Number • Boolean (True/False) • Object • Other (Sound, Video, etc.) • Does not change the current state of the world • Does not move / change objects

  3. What Functions Do • Check a current condition (run-time) • Get information about objects • Where they are • Size • Ask questions about the state of the world • As it is now  With program running

  4. Built In Functions • Proximity • Relation to other objects • Size • Spatial Relationship • Point of View

  5. Where to Use – Calling the Function • Anywhere that requires the type of information returned from the function • Number • Object • Boolean Example: Bopper.move (how far) Bopper.move (distanceTo(mole))

  6. Create Your Own Function • Exercise 6-1 #2 Create a new world with a car or truck. Write a program to make the 4 wheels of the car realistically turn forward as the car moves forward.

  7. Create Your Own Function • Like Creating a Method • Select Object in Object Tree • Select Functions from Details Window • Create New Function

  8. Create Your Own Function • Name • Type  Return Type • Must have a Return Type • Number • Boolean • Object Other

  9. Coding Function • Code Function • Cannot Delete the Return Statement • All functions return some Information

  10. Call the Function Function Call

More Related