1 package npw; 2 3 import painter.SPainter; 4 import shapes.SSquare; 5 import java.awt.*; 6 7 public class Stella { 8 private static Color randomColor() { 9 int rv = (int) (Math.random() * 256); 10 int gv = (int) (Math.random() * 256); 11 int bv = (int) (Math.random() * 256); 12 return new Color(rv, gv, bv); 13 } 14 public static void main(String[] args) { 15 // create the objects to think with 16 SPainter miro = new SPainter("Stella", 800, 800); 17 SSquare square = new SSquare(700); 18 int x = 0; 19 boolean color = true; 20 Color color1 = randomColor(); 21 Color color2 = randomColor(); 22 while (x <= 10) { 23 square.shrink(50); 24 if (color == true) { 25 miro.setColor(color1); 26 miro.paint(square); 27 color = false; 28 } else if (color == false) { 29 miro.setColor(color2); 30 miro.paint(square); 31 color = true; 32 } 33 x = x + 1; 34 } 35 } 36 }