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