/* * An invention of circles and squares that will output the same result each time it is ran */ package npw; import painter.SPainter; import shapes.SCircle; import shapes.SSquare; import javax.swing.*; import java.awt.*; public class Invention1 { private void paintTheImage() { SPainter first = new SPainter("Invention1", 700, 700); SCircle circle = new SCircle(30); SSquare square = new SSquare(30); first.setColor(Color.RED); first.moveToCenter(); first.faceNorth(); first.mbk(200); first.mrt(200); first.paint(circle); first.setColor(Color.BLUE); first.moveToCenter(); first.faceNorth(); first.mfd(200); first.mrt(200); first.paint(square); int i = 0; while ( i < circle.radius() ){ if (i == 5) { first.moveToCenter(); first.faceNorth(); first.mbk(200); first.mlt(200); first.paint(square); first.moveToCenter(); first.faceNorth(); first.mfd(300); first.mlt(300); first.setColor(Color.ORANGE); first.paint(circle); first.moveToCenter(); first.faceNorth(); first.mfd(200); first.mrt(300); first.setColor(Color.BLACK); first.paint(square); } if (i == 10) { first.moveToCenter(); first.faceNorth(); first.mfd(300); first.mrt(250); first.setColor(Color.RED); first.paint(circle); first.moveToCenter(); first.faceNorth(); first.mbk(250); first.mrt(300); first.setColor(Color.GREEN); first.paint(square); first.moveToCenter(); first.faceNorth(); first.mfd(150); first.mrt(300); first.setColor(Color.ORANGE); first.paint(circle); } i=i+1; } } public Invention1() { paintTheImage(); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Invention1(); } }); } }