Invention1.java
/* 
 * A program that paints random image every time it runs. 
 * And Only use one SCircle and one SSquare. 
 */

package npw;

import painter.SPainter;
import java.awt.Color;
import java.util.Random;

import shapes.SCircle;
import shapes.SSquare;

public class Invention1 {

    // Create the canvas and form basic structures.
    public static void main(String[] args){
        SPainter Kevin = new SPainter("Kuncheng's Invention", 1500, 1000);

        // Randomize some numbers.
        double SquareSide = ((double)Math.random() * 500 + 1);
        double CircleRadius = ((double)Math.random() * 250 + 1);
        double MoveX, MoveY, MoveXD, MoveYD, Scale;
        double NumOfSquares = ((double)Math.random() * 5 + 1);
        double NumOfCircles = ((double)Math.random() * 5 + 1);
        int i = 0;
        int k = 0;

        Random rgen = new Random();

        SSquare PrinzEugen = new SSquare(SquareSide);
        SCircle AdmiralHipper = new SCircle(CircleRadius);

        while (i < (int)NumOfSquares){
            int r = rgen.nextInt(256);
            int g = rgen.nextInt(256);
            int b = rgen.nextInt(256);
            Kevin.setColor(new Color(r,g,b));

            MoveX = ((double)Math.random() * 2 + 1);
            MoveY = ((double)Math.random() * 2 + 1);
            MoveXD = ((double)Math.random() * 650 + 100);
            MoveYD = ((double)Math.random() * 400 + 100);
            if ((int) MoveX == 1){
                Kevin.mlt(MoveXD);
            } else if ((int) MoveX == 2){
                Kevin.mrt(MoveXD);
            }
            if ((int) MoveY == 1){
                Kevin.mfd(MoveYD);
            } else if ((int) MoveY == 2){
                Kevin.mbk(MoveYD);
            }

            Kevin.paint(PrinzEugen);

            Kevin.moveToCenter();

            i++;
        }

        while (k < (int)NumOfCircles){
            int r = rgen.nextInt(256);
            int g = rgen.nextInt(256);
            int b = rgen.nextInt(256);
            Kevin.setColor(new Color(r,g,b));

            MoveX = ((double)Math.random() * 2 + 1);
            MoveY = ((double)Math.random() * 2 + 1);
            MoveXD = ((double)Math.random() * 650 + 100);
            MoveYD = ((double)Math.random() * 400 + 100);
            if ((int) MoveX == 1){
                Kevin.mlt(MoveXD);
            } else if ((int) MoveX == 2){
                Kevin.mrt(MoveXD);
            }
            if ((int) MoveY == 1){
                Kevin.mfd(MoveYD);
            } else if ((int) MoveY == 2){
                Kevin.mbk(MoveYD);
            }

            Kevin.paint(AdmiralHipper);

            Kevin.moveToCenter();

            k++;
        }
    }

}