/home/akc/NetBeansProjects/CS1/src/npw/Invention2.java |
1
2
3
4
5
6
7
8
9 package npw;
10
11 import java.awt.Color;
12 import painter.SPainter;
13 import shapes.SRectangle;
14
15
16
17 @author
18
19 public class Invention2 {
20
21
22 @param args
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