Checkpoint 18.1.1.
The following code is supposed to draw a picture consisting of four “lines”; each “line” has three squares.
Put the blocks in the right order and indentation. As usual, you will not use all the blocks.
square
make use of existing turtle procedures like forward
. But we can also use our own existing procedures to write other new procedures.row
procedure has one parameter - turtleName
. Whatever turtle is specified as the argument in the procedure call to row
will be called turtleName
inside row
. So because we call row(roger)
, turtleName
will mean roger
.row
procedure, we call the square
procedure: square(turtleName, 10)
. Because turtleName
refers to roger
at this point, that is the same as square(roger, 10)
. Because the first parameter of square is turtle
, that means any time we say turtle
in the square procedure, we are going to be working with roger
.row
to help write a grid
procedure that makes the final picture:grid
procedure, the parameter is called turtle
. Which is the same name that square
uses for its first parameter. It is OK for two different procedures to use the same name for their parameters. It can however be confusing… just because they have the same name, does not mean that they are always going to have the same value. Just like two people who both make a phone call to “Bob” may be calling the same person, or may not be.roger
is passed to grid
, which calls the turtle turtle
, and passes it to row
, which calls it turtleName
, which passes it to square
which calls it turtle
. Each of the procedures has its own “nickname” for the turtle that they are all working with.