Professional Documents
Culture Documents
Ronald M. Escarez
BTLE - ICT 3
Content
Subject matter/
Commands and functions
Lesson
C. Presenting
To give good commands, you
examples/
need to think about how much
instances of the
information is needed.
new lesson
For example, if you
commanded a robot to take
out the recycling, would your
commands be different than
they’d be for a person? You
couldn’t use words the robot
doesn’t already know and
understand.
Robots or computers need
very specific instructions for
D. Discussing new you to get the right results. To
concepts and execute instructions in
practicing new programming we use
skills 1 commands - these are words
used to perform a specific
operation.
example:
moveForward()
turnLeft()
collectGem()
1. moveForward()
You’ll need to write the 2. moveForward()
specific commands to move 3. turnLeft()
Byte across the puzzle and 4. moveForward()
collect gem. 5. moveForward()
6. collectGem()
Solve the puzzle: We will
now use a new command:
toggleSwitch()
1. Enter the commands to
move Byte across the puzzle
and to collect gem.
2. Continue entering
commands to move Byte to
the switch, then toggle it.
loop-swoop-pull
In programming, we call it
function
func tieMyShoe() {
loop swoop pull
}
In swift, we give function its
behavior by adding
commands inside the curly
braces.
ex: tieMyShoe()
Let’s go back to our puzzle,
as you noticed there’s no
turnRight() command
available for us. If Byte needs
to turn right to reach a gem,
how can you make that
happen?
1. collectSwitch()
I. Evaluating Solve the puzzle shown on 2. moveForward()
learning the presentation. 3. turnLeft()
4. collectSwitch()
5. moveForward()
6. moveForward()
7. turnLeft()
8. collectSwitch()
9. moveForward()
10. turnLeft()
11. collectSwitch()