1 2 /* 3 * Program to paint an image subject to set constraints. 4 */ 5 6 package npw; 7 8 import java.awt.Color; 9 import javax.swing.SwingUtilities; 10 import painter.SPainter; 11 import shapes.SCircle; 12 import shapes.SSquare; 13 14 public class Invention1 { 15 16 private void paintTheImage() { 17 SPainter painter = new SPainter("Invention 1", 800, 800); 18 SCircle circle = new SCircle(15); 19 SSquare square = new SSquare(15); 20 painter.setColor(Color.RED); 21 int i = 1; 22 while (i <= 5) { 23 painter.paint(circle); 24 circle.x2(); 25 painter.mbk(circle.radius()); 26 i = i + 1; 27 } 28 if (i == 6) { 29 painter.moveToCenter(); 30 i = 1; 31 while (i <= 5) { 32 painter.paint(square); 33 painter.mlt(square.side()*1.5); 34 square.x2(); 35 i = i + 1; 36 } 37 } 38 painter.moveToCenter(); 39 } 40 41 public Invention1() { 42 paintTheImage(); 43 } 44 45 public static void main(String[] args) { 46 SwingUtilities.invokeLater(new Runnable() { 47 public void run() { 48 new Invention1(); 49 } 50 }); 51 } 52 }