|
home—info—lects—labs—exams—hws
tutor/PIs—java.lang docs—java.util docs
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 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
You can test your function by (say)
Here's a bigger task:
Make a function
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 inthreeSmileys , just one of is mysteriously missing its eyes!?! This is becausepenUp andpenDown have been called from several different functions and not restored.
(It's a casualty of usingvoid methods and side-effects: our turtle has state that we're not specifying; perhaps every method should return aTrtl structure, and unit-tests could test that all fields of the returnedTrtl were the expected result.)
We will continue working on this in Thursday's lab, and you will submit it.
1 When you double click on a new turtle in this context, several things happen:
home—info—lects—labs—exams—hws
tutor/PIs—java.lang docs—java.util docs
©2010, Ian Barland, Radford University Last modified 2010.Sep.16 (Thu) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |