| ||||||||||
Midterm grades are now up in WebCT. Average was 92.75 – quite high. (I hope that doesn't mean that it's too easy and everyone's bored!) Mark Guzdial |
I've got a question about the midterm (in addition to the questions at the top of the page that nobody's touched yet...). Here was my answer to Problem 3: |
public class TurtleSquares { public static void main(String [] args){ Picture canvas = new Picture(500,500); Turtle t = new Turtle(canvas); for (int i = 0; i < 4; i++) {t.forward(100);t.turn(90);} for (int i = 0; i < 4; i++) {t.forward(150);t.turn(90);} for (int i = 0; i < 4; i++) {t.forward(200);t.turn(90);} canvas.show(); } }
But here's a solution that several people did: |
public class TurtleBoxes { public static void main(String [] args) { Picture canvas = new Picture(500,500); Turtle franklin = new Turtle(canvas); for (int i = 0; i < 12; i++) { if (i <4) {franklin.forward(100); franklin.turn(90);} else if (i < 8) {franklin.forward(150); franklin.turn(90);} else if (i < 12) //redundant {franklin.forward(200); franklin.turn(90);} } canvas.show(); } }
Having one big loop instead of three small loops looks a lot harder to me. Is it easier for you to think about? Why'd you do that way instead of the three smaller loops, or a single but simpler loop (e.g., some people created three separate turtles, and in a loop from 0 to 3, had one do a square of 200, while the other did 150, and the third did 100)? If it did the right thing, people who did the 12 step loop got full credit, and several did. I was just curious about which you found easier to think about and why. Thanks! Mark Guzdial |
ARGH! Thanks, Cassy – yes, "releasing" the column was necessary before you can see the grades. Please let me know if you still can't see the midterm grade. (I'll be on-line for only another 15 minutes now before heading back to the NSF meeting.) Mark Guzdial |