Change Contents of the Bubble
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Questions on HW2-Spring08

Ask questions on homework 2 here:

When we did turtles in Python, we were taught how to import time, so we could make the turtles move slowly. I'm having trouble with my code to make a curved letter, and if there was a way to do that in Java, so I could see what the turtle is doing.

Question: I've recently been getting an error on every code I write that does not recognize the class...am I missing a program or something?
Error: cannot find symbol
symbol  : class World
location: class LetterTurtle


Question: I made the J in my name by creating a straight line, and then a semi-circle from 0 - PI clockwise. While this seems to work, and I have made a J, I think trying to connect two PI/2 - 3PI/2 semi circles to make my S may be a bit "caveman-like". Is there a smoother way to create such letters?

Question: Is it enough credit to make an I with just a vertical line, or do I need the top and bottom horizontal lines? If I need the latter, how do I move to a position that is half of int x, because whenever I plug in an odd number to run the method, it cuts off the decimal, so the vertical line is not centered. Is there a way to make the moveTo function to take in a double?


Question: When I searched simpleTurtle for a pen width method, I found:
public void setPenWidth(int width) {
pen.setWidth(width);
However, when I use the method in my LetterTurtle, it says: pen has private access in SimpleTurtle
Indeed, in Pen, the width method is private. I tried creating a new object prior to the pen.setWidth command by putting Pen p = new Pen(); , and while that compiled (with a warning), the pen width still did not change. Ideas?
I can't seem to get the pen width adjusted. I looked in the Pen.java file for the command, but I'm not sure which one to use? setWidth? Or maybe I'm putting it in the wrong portion of my code?


Question: The HW says that the final result cannot contain a visible turtle. Since the picture is supposed to appear in a World, is there any way to get rid of the turtle, aside from making the pen width large enough to cover the turtle?

Question: I keep getting an error that is expecting ";" when ";" is obviously there... and it can't find the method circle, even though I copied the exact same circle code from class


Question: My program compiles only if the Turtle.java is also open. Can I assume that the TAs will have Turtle.java open or do I have to import it somehow in LetterTurtle.java?


Question: I just used the method setVisible(false) to hide the turtle and it worked. Do I have to change it?

Question: I read the above answers about pens, and I followed the advice, but I still keep getting errors that say SimpleTurtle has private access. This is what I'm trying to do:
  public void setPenWidth(int width){pen.setWidth(width); }
What am I doing wrong? It's between my main method and the other methods.

Question: For the extra credit, could the lower-case version of a letter count?

Question: I cant call the methods I create for drawing the letters. When I try to do this in the main method after creating a turtle ("fred.writeB(100,200)") I always get an error message telling me the symbol cant be found. Are we supposed to create the turtles in the main method? If not, how??




Link to this Page