![]() |
CSE 142 Summer 2001Homework #1Due: At the beginning of class, Monday, June 25, 2001 |
int myAge = 31;
double temperature = 67.2;
Rectangle rect = new Rectangle(); OBrowser.inspect(rect); OBrowser.inspect("hello bob"); OBrowser.inspect(new ArrayList());
(Hint: If you need to type a statement that is similar to one you've used before, try hitting the up-arrow key. This key takes you through a "history" of your previous inputs. With it, you can go back to a previous input, and using the left-arrow key and delete you can edit it to your taste.)
Pen p = new Pen(); p.turn(37); p.move(100);What is the position of the pen? (Hint, use the inspector!)
Now send the pen home and draw a squiral:
p.home(); p.erase(); p.squiral(100, 123, 5);What is the position and angle of the pen?
GWindow g = new GWindow(); Oval oval = new Oval(100, 150, 30, 60, Color.red, false); g.add(oval); Rectangle rect = new Rectangle(200, 250, 40, 40, Color.blue, true); g.add(square); Triangle tri = new Triangle(300, 30, 270, 70, 330, 70, Color.yellow, true); g.add(tri);List at least 3 qualities for that "belong" to each kind of shape: Rectangle, Triangle, Oval.
GWindow.picture();You should see a picture (something like modern art!). Your job is to show us a sequence of java statements that will draw a similar picture. We don't care too much about the exact positions of the objects, but there should be 5 objects (an oval, a triangle, two filled rectangles, and one unfilled rectangle) that overlap in a manner similar to the provided picture. (The easiest way to do this is to sketch out the positions on a piece of paper before creating the objects.) Create the objects by using the full interface for creating shapes (like the examples above).
(For the curious, more details about shapes can be found at http://www.cs.washington.edu/education/courses/142/01su/help/javadocs/. Click on the name of the kind of object you want (such as Triangle) to create and the browser should open a page describing the interface for that kind of object.)
Turn in your the java code you write (you can just copy it by hand, if you wish). You ought to be able to do this in no more than 15 statements (and probably as few as a half dozen). You'll want to start by creating your own graphics window (like the examples above)...