1 package npw; 2 import painter.SPainter; 3 import shapes.SCircle; 4 import shapes.SSquare; 5 6 import javax.swing.*; 7 import java.awt.*; 8 9 10 public class Invention1 { 11 12 13 public static void main(String[] args) { 14 // CREATE OBJECTS TO THINK WITH 15 SPainter miro = new SPainter("Invention1", 600, 600); 16 SSquare square = new SSquare(50); 17 SCircle circle = new SCircle(30); 18 19 miro.setColor(Color.ORANGE); 20 square.expand(50); 21 miro.paint(square); 22 square.shrink(50); 23 24 miro.mrt(square.side()); 25 miro.setColor(Color.GREEN); 26 miro.paint(circle); 27 miro.mlt(square.side()); 28 29 //GRAB THE INPUT INFORMATION 30 while (true) { 31 square.expand(50); 32 Color colorOfSquare = changeColor(); 33 miro.setColor(colorOfSquare); 34 miro.paint(square); 35 square.shrink(50); 36 miro.mrt(2*square.side()); 37 miro.setColor(Color.GREEN); 38 miro.paint(circle); 39 miro.mlt(2*square.side()); 40 miro.mlt(2*square.side()); 41 miro.setColor(Color.BLUE); 42 miro.paint(circle); 43 miro.mrt(2*square.side()); 44 45 } 46 47 } 48 private static Color changeColor() { 49 String color = JOptionPane.showInputDialog(null, "Change the color of the box?"); 50 if (color.equalsIgnoreCase("orange")) { 51 return Color.ORANGE; 52 } else if (color.equalsIgnoreCase("green")) { 53 return Color.GREEN; 54 } else if (color.equalsIgnoreCase("blue")) { 55 return Color.BLUE; 56 } else { 57 return Color.BLACK; 58 } 59 } 60 }