![]() |
![]() |
|
Allow network access?, just say
No(since we don't have administrator privileges).
Call
bonus thought: How many degrees did we end up turning, altogether? 360° -- the turtle rotated exactly once while drawing the figure! If you wanted to make a 5-sided pentagram or a 19-sided figure instead, can you guess how much each of the individual (5 or 19) turns should be?
Let's add a new function to
.)thiss
You can test your function by (say) by right-clicking on a turtle, and selecting your function. Try having your turtle do this:
Here's a bigger task:
Make a function
(Note that the smile doesn't have to exactly line up with the eyes;
it can be a bit off, to add to the creepy factor.)
How, exactly, will you draw the bowtie-ish thing, using two triangles? You must obey the first law of programming: No Repeated Code. If you want to (say) draw some triangles, just call the function you already wrote previously -- Easy!
hint: Have the turtle start in the middle of the bowtie-thing.
Note: your next problem is easier, if you decide that
to teacher:Common bug: Sometimes in
threeSmileys , just one of them is mysteriously missing its eyes!?! This is becausepenUp andpenDown have been called from several different functions and not restored.(It's a casualty of using
void methods and side-effects: our turtle has state that we're not specifying; perhaps every method should return aZagTrtl structure, and unit-tests could test that all fields of the returnedZagTrtl were the expected result.)
We will continue working on this in Thursday's lab, and you will check it off (with your partner).
(note the lower-casezagTrtl1
);z
This page licensed CC-BY 4.0 Ian Barland Page last generated | Please mail any suggestions (incl. typos, broken links) to ibarland ![]() |