Name:______________________________________
On Feb 11 we'll have 30-minute quiz. This homework is to help you review the techniques we've learned so far to help prepare for the quiz. On Wednesday we'll have a review day, no lab. We'll go over this HW and do some problems out of the book.
Answer the following questions:
World w = new World(); Turtle t = new Turtle(w); int d = 100; for (int i = 0; i < 100; i++) { t.forward(d); t.turn(25); }
World w = new World(); Turtle t = new Turtle(w); int d = 100; for (int i = 0; i < 100; i++) { t.forward(d); t.turn(25); }
World w = new World(); Turtle t = new Turtle(w); int d = 100; for (int i = 0; i < 100; i++) { t.forward(d); t.turn(25); }
World w = new World(); Turtle t = new Turtle(w); int d = 100; for (int i = 0; i < 100; i++) { t.forward(d); t.turn(25); }
World w = new World(); Turtle t = new Turtle(w); int d = 100; for (int i = 0; i < 100; i++) { t.forward(d); t.turn(25); }
World w = new World(); Turtle t = new Turtle(w); int d = 100; for (int i = 0; i < 100; i++) { t.forward(d); t.turn(25); }
World w = new World(); Turtle t = new Turtle(w); int d = 100; for (int i = 0; i < 100; i++) { t.forward(d); t.turn(25); }
Color R G B Black White Blue
(10,20,0) (40,255,100) (50,50,50) (0,10,142) (80,24,129) (28,88,188)
Consider the following Picture
method:
void swapColors() { Pixel[] pixelArray = this.getPixels(); for (Pixel p : pixelArray) { int r = p.getRed(); int g = p.getGreen(); int b = p.getBlue(); p.setColor(new Color(g,b,r)); } }
In the following table indicate the value of the pixels
after the swapColors
method is called on the above picture.
Turtle t1 = new Turtle(new World()); Turtle t2 = t1; t1.forward(100); t2.turn(90);
What happens with the above code? How many Turtle objects exist in the above code? Explain why.