CS1 Standard Demo Page

The following text was written to the standard output stream when the Stella.java program was executed from Netbeans.

 /*
  * Program in which (a) the number of concentric squares will be read from a 
  * dialog box, (b) two random colors will be chosen, (c) canvas is 800x800 and 
  * the largest square is 700x700.
  */
 package npw;

import java.awt.Color;
import javax.swing.JOptionPane;
import painter.SPainter;
import shapes.SSquare;

/**
 *
 * @author ecuevas
 */


public class Stella {

    private static Color randomColor() {
        int rv = (int) (Math.random() * 256);
        int gv = (int) (Math.random() * 256);
        int bv = (int) (Math.random() * 256);
        return new Color(rv, gv, bv);
    }

    public static void main(String[] args) {
        // create the objects to think with
        SPainter miro = new SPainter("Stella", 800, 800);
        SSquare square = new SSquare(700);

        int x = 0;
        boolean color = true;
        Color color1 = randomColor();
        Color color2 = randomColor();
        while (x <= 10) {
            square.shrink(50);
            if (color == true) {
                miro.setColor(color1);
                miro.paint(square);
                color = false;
            } else if (color == false) {
                miro.setColor(color2);
                miro.paint(square);
                color = true;
            }

            x = x + 1;
        }

    }

}