pinwheel
block to make asterisk
and polygon
blocks.You can use your general-purpose pinwheel procedure to create other, simpler special-purpose procedures that each do a particular job.
pinwheel
block to create a more specialized asterisk
block.
asterisk
with two variables: one for the number of branches and one for the length of each branch. You may wish to review how to make a new block at Unit 1 Lab 2 Page 3: Making Your Own Block.pinwheel
so that it correctly draws an asterisk.polygon
block that uses pinwheel
with appropriate inputs to draw a polygon with a given number of sides and side length.Using a block you've already written to help write another block is an example of abstraction. Abstraction is arguably the most important idea in computer science, but it doesn't have a simple definition. Here, abstraction means using a more general block (pinwheel
) to create two more specific blocks (asterisk
and polygon
). There are other kinds of abstraction too, and we'll point them out as they come up.
In the meantime, if you find yourself wanting to copy code from one place to another, consider abstracting by writing a general block to use in both places instead.
pinwheel
and see how you're using it in polygon
, you'll see that there are steps that you don't really need for the case of a polygon. Write another version of polygon
built directly out of primitive blocks (move
, turn
and so on). How simple can you make it?pinwheel
block code one last time to create a circle
block that accepts one input for the size.random
block together with set pen color
and set pen size
to draw a variety of shapes.