Stella.java
/* 
 A program to paint a given number of concentric squares. 
 */

package npw;

import painter.SPainter;
import shapes.SSquare;
import java.awt.Color;
import javax.swing.*;
import java.util.Scanner;

public class Stella {

    private void paintTheImage() {

        int number = getNumber("number of concentric squares");
        int shrunk = 700/number;
        SPainter brush = new SPainter("Stella", 800, 800);
        SSquare square = new SSquare(700);
        Color one = randomColor();
        Color two = randomColor();

        int i = 0;
        while (i < number) {
            if (i%2 == 0) {
                brush.setColor(one);
                } else {
                brush.setColor(two);
                }
                brush.paint(square);
                square.resetSide((int) (square.side()-shrunk));
                i = i + 1;
            }
    }

    private static int getNumber(String prompt) {
        String nss = JOptionPane.showInputDialog(null,prompt+"?");
        Scanner scanner = new Scanner(nss);
        return scanner.nextInt();
    }

    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 Stella() {
        paintTheImage();
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new Stella();
            }
        });
    }
}