Presentation on theme: "Introduction to touchdevelop if then else conditional statement Disclaimer: This document is provided “as-is”. Information and views expressed in this."— Presentation transcript:
introduction to touchdevelop if.. then.. o “if condition is true then do stuff” if balance < 0 then social→send email(“me”, “empty!”, “”) o tell the phone to run code only if the condition is met
introduction to touchdevelop if.. then.. else.. o “if condition is true then do stuff else do other stuff” if balance < 0 then social→send email(“me”, “empty!”, “”) else “enough balance!” →post to wall ☁ http://touchdevelop.com/pddxhttp://touchdevelop.com/pddx
introduction to touchdevelop editing o tap + in the statement menu o tap the if button
introduction to touchdevelop editing o edit the condition o tap the hardware back button when done
introduction to touchdevelop exercises ►”play a random song; on shake, toggle the player between resume and pause” ►”ask the user a question (‘1+2=?’); if false, vibrate, if true play a victory song” wall→ask number to ask a number to the user ►”ask the user a duration in seconds; if the duration is between 0 and 5, vibrate for that amount of seconds” ☀ you can add an if statement inside of then or else.
introduction to touchdevelop true/false maths o known as Boolean logic o a Boolean condition may be true or false ortruefalse true falsetruefalse andtruefalse true false nottruefalse true
introduction to touchdevelop exercises ► true and false = ? ► false or true = ? ► not true = ? ► true or not true = ? ► not true and not false = ? ► not true or not false= ? in doubt, try it out on the phone…
introduction to touchdevelop title o item 1 o item 2 song→post to wall ☀ anecdote ☁ http://touchdevelop.com/velk (link to sample)http://touchdevelop.com/velk ► an exercise ✿ a reference
Your consent to our cookies if you continue to use this website.