Tuesday, July 29, 2014

Solutions: Art with Pro-Bot - Snowmen

Let's first write the programs for the squares of sides 6 cm, 4 cm and 2 cm.  We shall store these are three different procedures, say in Proc1, Proc2 and Proc 3.

Here is one way of writing the programs:


Proc 1      // procedure for 6 cm side square
Rpt 4 [
Fd 6
Rt
]


Proc 2      // procedure for 4 cm side square
Rpt 4 [
Fd 4
Rt
]


Proc 3      // procedure for 2 cm side square
Rpt 4 [
Fd 2
Rt
]



Now let's draw the small snowman using the above procedures. From Main, the program shall be written as:


// Program for the Small Snowman


Proc 2
Fd 4
Rt
Fd 1
Lt
Proc 3


You can use the above procedures for drawing the large snowman as well. From Main, the program for the large snowman can be written as:


// Program for the Large Snowman


Proc 1
Fd 6
Rt
Fd 1
Lt
Proc 2
Fd 4
Rt
Fd 1
Lt
Proc 3









No comments:

Post a Comment