/home/akc/NetBeansProjects/CS1/src/npw/Invention2.java
 1 /*
 2  * Painting an image subject to the following constraints:
 3  * 1. It uses at least one while statement in a nontrivial way
 4  * 2. It uses at least one if statement in a nontrivial way
 5  * 3. It features solely rectangles, all generated from a single rectangle
 6  * 4. The program takes no input from the user of the program
 7  * 5. It creates a different image each time the program is run
 8  */
 9 package npw;
10 
11 import java.awt.Color;
12 import painter.SPainter;
13 import shapes.SRectangle;
14 
15 /**
16  *
17  * @author akc
18  */
19 public class Invention2 {
20 
21     /**
22      * @param args the command line arguments
23      */
24     public static void main(String[] args) {
25         SPainter painter = new SPainter ("Non-Deterministic", 600, 600);
26         int a = 10;
27         int b = 15;
28         while (a < 500) {
29             if (b < 300) {
30                 painter.setColor(randomColor());
31                 SRectangle rectangle = new SRectangle (a,b);
32                 painter.draw(rectangle);
33                 b = b + (int)(Math.random()*20);
34                 a = a + (int)(Math.random()*25);
35             }
36         }
37     }
38 
39     private static Color randomColor() {
40         int rv = (int)(Math.random()*256);
41         int gv = (int)(Math.random()*256);
42         int bv = (int)(Math.random()*256);
43         return new Color (rv,gv,bv);
44     }
45     
46 }
47