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