/home/rkanin/NetBeansProjects/CS1/src/npw/Stella.java
 1 
 2 /*
 3  2  * To change this license header, choose License Headers in Project Properties.
 4  3  * To change this template file, choose Tools | Templates
 5  4  * and open the template in the editor.
 6  5  */
 7   package npw;
 8   
 9  import java.awt.Color;
10  import java.util.Random;
11  import java.util.Scanner;
12  import javax.swing.JOptionPane;
13  import painter.SPainter;
14  import shapes.SSquare;
15  
16  /**
17   *
18   * 
19   */
20  public class Stella {
21  
22      /**
23       * @param args the command line arguments
24       */
25      public static void main(String[] args) {
26          int NumberOfSquares = getNumber("Number of Concentric Squares...");
27          
28          SPainter richard = new SPainter("Stella", 800, 800);
29          
30          SSquare ConcentricSquaresRK = new SSquare(700);
31          
32          
33          Color ColorR = randomColor();
34          Color ColorK = randomColor();
35          double shrink = 700.0 / NumberOfSquares;
36          int i = 1;        
37          while(i< NumberOfSquares){    
38              if (i%2==0){
39                 richard.setColor(ColorR);              
40              }else{
41                 richard.setColor(ColorK);               
42              }
43              i = i + 1;
44              ConcentricSquaresRK.shrink(shrink);
45             richard.paint(ConcentricSquaresRK);
46             richard.moveToCenter();
47         }                     
48                
49          
50      }
51  
52       private static Color randomColor() {        
53         Random rgen = new Random();
54         int r = rgen.nextInt(256);
55         int g = rgen.nextInt(256);
56         int b = rgen.nextInt(256);
57         return new Color(r,b,g);
58           }
59  
60      private static int getNumber(String prompt) {
61          
62         String ray = JOptionPane.showInputDialog(null,prompt+"?");
63         Scanner scanner = new Scanner(ray);
64          return scanner.nextInt();
65         }
66     
67  }
68  
69 
70