// Shapes.java: Fig 5.26 from Deitel & Deitel, Java: How to Program
// Demonstrates drawing different shapes.
//
// Modified for CSC 121 - Spring 2005 
// Berry College - Nadeem Abdul Hamid

import java.awt.Graphics;
import javax.swing.JPanel;

public class Shapes extends JPanel {

    private int choice;    // user's choice of which shape to draw

    // constructor sets the user's choice
    public Shapes( int userChoice ) {
        choice = userChoice; 
    } // end Shapes constructor

    // draws a cascade of shapes starting from the top left corner
    public void paintComponent( Graphics g ) {
        super.paintComponent( g );
        
        for ( int i = 0; i < 10; i++ ) {
            // pick the shape based on the user's choice
            switch ( choice ) {
               case 1: // draw rectangles
                   g.drawRect( 10 + i * 10, 10 + i * 10,
                               50 + i * 10, 50 + i * 10 );
                   break;
               case 2: // draw ovals
                   g.drawOval( 10 + i * 10, 10 + i * 10,
                               50 + i * 10, 50 + i * 10 );
                   break;
            } // end switch
        } // end for
    } // end method painComponent

} // end class Shapes

