/* A program to create a visually interesting canvas with an if and while statement. */ package npw; import painter.SPainter; import shapes.SCircle; import shapes.SSquare; import java.awt.Color; import javax.swing.SwingUtilities; public class Invention1 { private void paintTheImage() { SPainter thing = new SPainter("Invention1", 420, 420); SSquare square = new SSquare(50); SCircle dot = new SCircle(75); thing.setColor(Color.darkGray); thing.paint(square); thing.mfd(100); thing.paint(dot); thing.mbk(200); thing.paint(dot); thing.mbk(75); thing.center(); dot.setRadius(25); int i = 1; while (i < 8) { if (i == 1) { thing.setColor(Color.red); } else if (i==2) { thing.setColor(Color.orange); } else if (i==3) { thing.setColor(Color.yellow); } else if (i==4) { thing.setColor(Color.green); } else if (i==5) { thing.setColor(Color.blue); } else if (i==6) { thing.setColor(Color.magenta); } else if (i==7) { thing.setColor(Color.pink); } thing.paint(dot); thing.mfd(dot.diameter()); i = i + 1; } } public Invention1() { paintTheImage(); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { new Invention1(); } }); } }