{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

12-Assignment-2-Simple-Java

# 12-Assignment-2-Simple-Java - CS106A Handout 12 April 8th...

This preview shows pages 1–3. Sign up to view the full content.

CS106A Handout 12 Spring 2011 April 8 th , 2011 Assignment 2: Simple Java Programs This assignment was written by Eric Roberts. Your job in this assignment is to write programs to solve each of these problems. To help you get started early, we’ll be holding YEAH (Your Early Assignment Help) hours on Monday, April 11 th at 7 p.m. in Hewlett 200. Due: Monday, April 18 th at 5:00 p.m. Problem 1: Brick Pyramids Write a GraphicsProgram subclass that draws a pyramid consisting of bricks arranged in horizontal rows, so that the number of bricks in each row decreases by one as you move up the pyramid, as shown in the following sample run: The pyramid should be centered at the bottom of the window and should use constants for the following parameters: BRICK_WIDTH The width of each brick (30 pixels) BRICK_HEIGHT The height of each brick (12 pixels) BRICKS_IN_BASE The number of bricks in the base (12) The numbers in parentheses show the values for this diagram, but you must be able to change those values in your program and still produce a reasonable picture. Problem 2: Rainbow Write a GraphicsProgram subclass that draws a rainbow that looks like this:

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
The colors of the stripes are clear in the web version of the picture, but are hard to see in the black-and-white handout. Starting at the top, the six arcs are red, orange, yellow, green, blue, and magenta, respectively; cyan makes a lovely color for the sky. At first glance, it might seem as if you need to draw arcs on the screen, even though you won’t actually learn about the GArc class until Chapter 8. As it turns out, that class doesn’t really help much. The program that produced the diagram shown at the bottom of the previous page uses only circles, although seeing how this is possible forces you to think outside the box—in a literal rather than a figurative sense. The common center for each
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 7

12-Assignment-2-Simple-Java - CS106A Handout 12 April 8th...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online