CS 140 - Lab 4, Thursday Sep 11

Objectives

  1. Explore various methods to creat Java graphics.

The Lab

Part I - Finishing Mr. Blockhead

In this lab we are going to adorn our Mr. Blockhead drawing with some additional facial features. Start with the program we began writing the last class, except name your class Lab4 and save it in a file named Lab4.java. Make sure all of your drawing commands are relative to the upper left corner of the picture.

  1. Give Mr. Blockhead a smile. One way to do this is to erase the top half of the oval by writing over it with a shape that is the same color as the background. Figure out which shape(s) to use and where to place it. Be careful not to erase part of his nose.
  2. Make Mr. Blockhead's eyes a little bigger and give him pupils.
  3. Give Mr. Blockhead some ears.
  4. Grow some hair on his head. To do this use the drawLine(x1,y1,x2,y2) command.
  5. Across Mr. Blockhead's forhead write the text "Blockhead". To write text onto a picture use the graphics command drawString("Some text",x,y); writes the text Some text at coordinate (x,y) on the picture.

Part II - Drawing a Bullseye

Create a new drawing from scratch that draws a bullseye like below. Put this code after the code for Mr. Blockhead. Make a 900 by 900 picture and give the biggest (outer) circle a diameter of 500. Don't for get to make the crosshairs in the center. Center your bullseye in the canvas.

When you finish make sure you have me or Dan check your work.