Presentation is loading. Please wait.

Presentation is loading. Please wait.

Variables, operators, canvas, and multimedia Dr. Reyes.

Similar presentations


Presentation on theme: "Variables, operators, canvas, and multimedia Dr. Reyes."— Presentation transcript:

1 Variables, operators, canvas, and multimedia Dr. Reyes

2 2 Outline Variables Operators Canvas Boolean Expressions If, if/else Statements

3 Variables

4 4 Properties and variables In general the memory is a set of cells or slots, like spread sheet, where we store data. Properties and variables are named memory slots We use variables and properties to store information used within our app.

5 5 Operations with variables Variable definition Name the variable Assign initial value Using the variable Set a value Get the value

6 6 Variables on AppInventor Numeric Variables: –http://www.cs.trincoll.edu/~ram/q/110/numeric_variables.htmlhttp://www.cs.trincoll.edu/~ram/q/110/numeric_variables.html Numeric Variables: –http://www.cs.trincoll.edu/~ram/q/110/text_variables.htmlhttp://www.cs.trincoll.edu/~ram/q/110/text_variables.html

7 Operators

8 8

9 9 Reference Arithmetic operators and other math blocks –http://experimental.appinventor.mit.edu/learn/reference/blocks/math.htmlhttp://experimental.appinventor.mit.edu/learn/reference/blocks/math.html Logic operators –http://experimental.appinventor.mit.edu/learn/reference/blocks/logic.htmlhttp://experimental.appinventor.mit.edu/learn/reference/blocks/logic.html

10 10 Comment your source code or blocks so you can easily remember and others can understand them. Comments

11 Logic Control if – if-else statement

12 12 An App Consists of Event-Handlers That Can Ask Questions and Branch Many responses to events are not sequential, but contain branches and loops. The app is allowed to ask questions and determine its course based on the answers. We say that such apps have conditional branches: Conditions are questions such as “has the score reached 100?” or “did the text I just receive is from Joe?” Depending on the condition evaluation (true or false) either B1 or B2 are going to be executed, but not both.

13 13 If and if/else statement Test statement If test statement is TRUE, then do the following… If test statement is TRUE, then do the following.. If test statement is FALSE, then do the following… If test statement is FALSE, skip the if statement

14 14 Conditions are Boolean Conditions are Boolean, meaning they return true or false. They test the value of properties and variables using the following logical operators: These operators can be found in the Math and Logic drawers.

15 15 Algorithm – Pseudo Code // Use if statement to check the default size. defaultSize = 5; smallSize = 3; bigSize = 8; If defaultSize 3 Display in LabelResult = The dot size is set to default; end

16 16 Some examples

17 17 OpenLab and Blackboard Check OpenLab for labs. Check Blackboard for quizzes. Start working on your project. Study for the second exam.


Download ppt "Variables, operators, canvas, and multimedia Dr. Reyes."

Similar presentations


Ads by Google