/home/akc/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.Scanner;
10 import javax.swing.JOptionPane;
11 import painter.SPainter;
12 import shapes.SSquare;
13 
14 /**
15  *
16  * @author akc
17  */
18 public class Stella {
19 
20     /**
21      * @param args the command line arguments
22      */
23     public static void main(String[] args) {
24         //SETTING UP VALUES
25         int nrOfSquares = getNumber("Number of Squares");
26         Color one = randomColor();
27         Color two = randomColor();
28         double increment = 700/nrOfSquares;
29         SPainter painter = new SPainter ("Stella", 800, 800);
30         
31         //PAINTING THE IMAGE
32         SSquare square = new SSquare (700);
33         int i = 1;
34         while (nrOfSquares > 0) {
35             if (i%2 == 0) {
36                 painter.setColor(two);
37             } else {
38                 painter.setColor(one);
39             }
40             painter.paint(square);
41             square.shrink(increment);
42             nrOfSquares = nrOfSquares - 1;
43             i = i + 1;
44         }
45     }
46 
47     private static int getNumber(String prompt) {
48         String nss = JOptionPane.showInputDialog(null, prompt + "?");
49         Scanner scanner = new Scanner(nss);
50         return scanner.nextInt();
51     }
52 
53     private static Color randomColor() {
54         int rv = (int)(Math.random()*256);
55         int gv = (int)(Math.random()*256);
56         int bv = (int)(Math.random()*256);
57         return new Color (rv,gv,bv);
58     }
59     
60 }
61