Homework02.java

package com.bozoid.cis370.hw02;

import java.util.Random;


/**
Testbed class for CIS370 homework #2.

@author Walt Leipold
*/
public class Homework02
{
    public static void main(String[] argv)
    {
        Shape[] shapes = new Shape[20];
        Random rand = new Random();

        for (int i=0; i<shapes.length; i++) {
            double x = rand.nextInt(72);
            double y = rand.nextInt(22);
            double w = rand.nextInt(40);
            double h = rand.nextInt(20);

            switch(rand.nextInt(4)) {
                case 0:
                    shapes[i] = new Line(x,y,x+w,y+h);
                    break;
                case 1:
                    shapes[i] = new Rectangle(x,y,w,h);
                    break;
                case 2:
                    shapes[i] = new Circle(x,y,w);
                    break;
                case 3:
                    shapes[i] = new Ellipse(x,y,w,h);
                    break;
                }
            }

        for (int i=0; i<shapes.length; i++)
            System.out.println(shapes[i]);
    }
}