canvas
and the various shapes it can drawMyPetApp
write the following procedures:
drawPet( x, y, size )
This procedure draws your favorite pet animal centered at the given (x, y)
of the given size
.
x, y, size
. Once you decide on what animal you plan to draw rename them so that they are more descriptive and reflect what they represent about your pet.
For example size
could be the width or the height of the pet, depending on which is more convenient. If you are drawing a giraffe, size
could specify the height of the giraffe; if you are drawing an elephant, size
could specify the width of the elephant.
The anatomical features of the animal should be relative to the given center and the given size of the animal, so that larger (smaller) sizes will produce larger (smaller) animals.
It is up to you to decide whether (x, y)
represent the center of the torso, the center of the face of the animal, etc. Just name them appropriately.
Occasionally include notes/comments in the code to make it clear what part is being drawn.
drawScene()
This procedure draws a simple outdoor scene that covers the whole screen (see notes on canvas
on the Readings List for screen dimensions).
public void run()
draw the scene (only once) and then draw 3-4 animals of different sizes at various locations.
Each procedure mentioned above should include the following:
Point
and Image
Polygon
is optional for advanced or bored studentsText
is used only in drawScene
cs111
(where you run DrJava) hw/MyPetApp/src/cs1/MyPetApp
(this is where your code is saved) MyPetApp.java
(ignore the other files)