/home/rkanin/NetBeansProjects/CS1/src/npw/Invention2.java
 1 /*
 2  * Program that paints 100 red, yellow and orange balloons in a blue sky
 3  * It will feature commands
 4  */
 5 package npw;
 6 
 7 import java.awt.Color;
 8 import java.util.Random;
 9 import javax.swing.SwingUtilities;
10 import painter.SPainter;
11 import shapes.SRectangle;
12 
13 
14 
15 /**
16  *
17  * @author rkanin
18  */
19 public class Invention2 {
20     
21     // REQUIRED INFRASTRUCTURE
22     
23     public Invention2() {
24         paintTheImage();
25     }
26 
27     public static void main(String[] args) {
28         SwingUtilities.invokeLater(new Runnable() {
29             public void run() {
30                 new Invention2();
31             }
32             
33         });
34 
35     }
36     
37     // THE PAINTER DOING ITS THING
38     
39     private void paintTheImage() {
40         int rectkside = 17;
41         SPainter painter = new SPainter("Invention2", 700, 700);
42         background(painter);       
43         rectgen(painter, rectkside); 
44     }
45     
46    
47     private void background(SPainter painter) {
48         painter.setColor(Color.BLUE);
49         
50         
51     }
52 
53     private void rectgen(SPainter painter, int rectkside) {
54         int i = 1;
55         while ( i <= rectkside ) {
56             rectrk(painter);  
57             i = i + 1;
58             painter.mlt(200);
59             painter.mfd(200);
60         }
61     }
62 
63     private void rectrk(SPainter painter) {
64         Random rgen = new Random();
65         int rn = rgen.nextInt(3);
66         if ( rn == 0 ) {
67             painter.setColor(Color.RED);
68         } else if ( rn == 1 ) {
69             painter.setColor(Color.BLACK);
70         } else { 
71             painter.setColor(Color.CYAN);
72         }
73         painter.move();
74  
75         SRectangle rectk = new SRectangle(50,200);
76         painter.paint(rectk);
77         painter.setColor(Color.BLACK);
78         painter.draw(rectk);
79     }
80     
81     
82     }
83