Invention2.java
1    package npw;
2    
3    import painter.SPainter;
4    import shapes.SRectangle;
5    
6    import javax.swing.*;
7    import java.awt.*;
8    import java.util.Random;
9    
10   public class Invention2 {
11       private void interpreter() {
12           //CREATE OBJECTS TO THINK WITH
13           SPainter miro = new SPainter("Dot Thing", 400, 400);
14           paintRotation(miro);
15       }
16   
17       private static void paintRotation(SPainter miro){
18           int i = 0;
19           miro.mlt(150);
20           SRectangle rect = new SRectangle(300, 100);
21           miro.paint(rect);
22   
23           while (i < 10) {
24               miro.mrt(50);
25               Random rgen = new Random();
26               int r = rgen.nextInt(256);
27               int g = rgen.nextInt(256);
28               int b = rgen.nextInt(256);
29               miro.setColor(new Color(r, g, b));
30               if (i == 6) {
31                   miro.setColor(Color.BLACK);
32                   miro.paint(rect);
33               }
34               miro.paint(rect);
35               i = i + 1;
36           }
37       }
38   
39       //INFRASTRUCTURE FOR SOME SIMPLE PAINTING
40   
41       public Invention2() {
42           interpreter();
43       }
44   
45       public static void main(String[] args) {
46           SwingUtilities.invokeLater(new Runnable() {
47               ;
48               public void run () {
49                   new Invention2();
50               }
51           });
52       }
53   }
54   
55