Invention2.java
package assignment4;

import painter.SPainter;
import shapes.SCircle;
import shapes.SRectangle;
import shapes.SSquare;

import javax.swing.*;
import java.awt.*;

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

    public Invention2() {
        paintimage();
    }

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

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

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

    private void paintimage() {
        int d = 100;
        SPainter Kalarts = new SPainter("InVeNtIoN TwO", 600, 600);
        while (d >= 1) {
            d = d - 1;
            double madness = (Math.random() * 50);
            double madness2 = (Math.random() * 50);
            SRectangle Calarts = new SRectangle(madness, madness2);
            Kalarts.move();
            Kalarts.paint(Calarts);
            if (madness <= 25) {
                Kalarts.setColor(randomColorblue());
            } else if (madness2 <= 25) {
                Kalarts.setColor(randomColorgreen());
            } else {
                Kalarts.setColor(randomColorred());
            }
        }
    }
}