Presentation is loading. Please wait.

Presentation is loading. Please wait.

Objects, Functions and Parameters

Similar presentations


Presentation on theme: "Objects, Functions and Parameters"— Presentation transcript:

1 Objects, Functions and Parameters
Susan Ibach | Technical Evangelist Sage Franch | Microsoft Student Partner

2 Mastering a few key concepts will allow you to understand your code!
Objects Functions Parameters Properties

3 Objects

4 An object is a representation of something in a game or app
Set lives in the game to 1. noun object Examples of objects we use in code include A button A character in our game The game itself Grammar is different depending on language.

5 What objects do we have in our game?
obstacle hero board game

6 Functions

7 A function is an action associated with an object
Set lives in the game to 1. verb function Functions allows us to Manipulate the object (make it bigger, smaller, faster) Create new objects (add text or a picture to the board) Perform an action (start a timer, end the game, remove a life) Grammar is different depending on language.

8 Different objects have different functions
Functions on the game object: Functions on the hero object: This is only a few of the functions!

9 Objects and Functions in our game

10 What are those symbols? Indicates the function being called for this object Indicates that this is a “special” object, with LOTS of functions.

11 Parameters

12 A parameter is a value passed to a function
Set lives in the game to 1. parameter Parameters allow you to control what a function will do How big to make an object How fast to make an object move How many points to score Grammar is different depending on language.

13 Not all functions accept parameters
Sometimes functions just perform a specific action and you don’t need to provide extra information Some functions don’t take parameters. Some of what you see here are “properties” on objects. Properties will come later.

14 Some functions return an object
Some functions, like set life(), just do something Like change the number of lives in a game But some functions, return something… This function returns an object. We are storing the returned object in a variable called board. (Board can have its own functions and properties!)

15 Think of functions that return objects as vending machines…

16 Or…

17 Properties

18 Properties give us information about our objects
How big is our hero? width or height How many lives does the game have left? life How fast is our hero moving? speed

19 We can change the value of a property by calling a function and passing in a parameter
Change the size of our hero set width(100) or set height(100) Change the number of lives in our game set life(3) Change the speed of our hero set speed(400)

20 Resize our hero & Change number of lives in the game

21 Your challenge Resize your hero
Set number of lives in your game to a value of your choosing

22 Congratulations! You can speak code.

23 Vocabulary and concepts
Object: A self-contained entity that includes both functions and data (properties). An object in code is like a noun in a sentence. Function: A procedure or routine that does a specific task. A function in code is like a verb in a sentence. Some functions just do something, but some return an object Parameter: A value (or variable) that is passed to a function. Property: An attribute of an object A property is like an adjective in a sentence

24


Download ppt "Objects, Functions and Parameters"

Similar presentations


Ads by Google