Invention2.java
/* 
 program to create a visually interesting canvas with an if and while statement that is different each time. 
 */

package npw;

import painter.SPainter;
import shapes.SRectangle;
import java.awt.Color;
import javax.swing.SwingUtilities;

public class Invention2 {

    private void paintTheImage() {
        SPainter brush = new SPainter("Invention2", 400, 400);
        SRectangle rectangle = new SRectangle(50, 100);
        brush.move();

        int i = 1;
        while (i < 11) {
            if (i == 1) {
                brush.setColor(randomColor());
            } else if (i == 2) {
                brush.setColor(randomColor());
            } else if (i == 3) {
                brush.setColor(randomColor());
            } else if (i == 4) {
                brush.setColor(randomColor());
            } else if (i == 5) {
                brush.setColor(randomColor());
            } else if (i == 6) {
                brush.setColor(randomColor());
            } else if (i == 7) {
                brush.setColor(randomColor());
            } else if (i == 8) {
                brush.setColor(randomColor());
            } else if (i == 9) {
                brush.setColor(randomColor());
            } else if (i == 10) {
                brush.setColor(randomColor());
            }
            brush.paint(rectangle);
            brush.draw(rectangle);
            brush.move();
            i = i + 1;
        }
    }

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

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

}