next up previous
Next: Use a bounding box Up: Homework 4: Snowpeople! Previous: Homework 4: Snowpeople!

New stationery!

1.
Create a new project named Snowperson.prj, using the project stationery named cs115SlateStationery. Run it. A new window should appear with a bunch of blue circles and a bunch of red circles. This window is the Slate.

Unlike the other programs we ran, there is no console window. However, if you add a print or println statement, the console window will appear. For graphical applications, the console is useful for debugging.

I found that I could not close the Slate window by clicking on it, which is probably good, because it will remind you to quit from the interpreter every time you run the program.

2.
Look over the source code as it currently exists and make sure you understand all the code in draw. The method named anim is there for your entertainment, but we will not be using it for this assignment. You should remove it.

3.
The Slate class appears immediately after the cs151 class. You might want to check it out, although a lot of it will not make sense at this point.

4.
Fiddle with the statements in draw and see what effect your changes have. Try out the various drawing commands. For more information about them, see

http://java.sun.com/products/jdk/1.1/docs/api/java.awt.Graphics.html

5.
Change the width or height of the Slate and run the program again. You should see that the image adjusts its size and proportions to fit the size of the window. You are going to write drawing programs that do the same thing. The idea is to use variables and parameters to make programs more general; in this case the generality is that we can draw images that are any size or location.


next up previous
Next: Use a bounding box Up: Homework 4: Snowpeople! Previous: Homework 4: Snowpeople!
Allen B. Downey
1999-09-29