package npw; import painter.SPainter; import shapes.*; import javax.swing.*; import java.awt.*; /*thsi program make dots in which it contains exactly 9 painted (filled in) circles it contains circles of exactly 4 different sizes it contains circles of exactly 4 different colors none of the circles touch the image is symmetric about the Y-axis not all of the circles touch the Y-axis */ public class Dots { private void paintTheImage() { //making the objects used in the rest of the code vvvvv SPainter painter = new SPainter(" The Dots Problem ",900,900); SCircle dot1 = new SCircle( 50); SCircle dot2 = new SCircle( 100); SCircle dot3 = new SCircle( 75); SCircle dot4 = new SCircle( 25); //giving the objects names painterBlueCircle(painter, dot1); painterRedCircle(painter, dot2); painterpurpleCircle(painter, dot3); painterGreenAndOrangeCircle(painter, dot4); } //the first circle, which is blue private void painterBlueCircle(SPainter painter, SCircle dot1) { painter.setColor(Color.BLUE); painter.paint(dot1); } //the second circle, which is red private void painterRedCircle(SPainter painter, SCircle dot2) { painter.setColor(Color.RED); painter.mfd(200); painter.paint(dot2); painter.moveToCenter(); painter.mbk( 200); painter.paint(dot2); painter.moveToCenter(); } //the third circle which is purple private void painterpurpleCircle(SPainter painter, SCircle dot3) { painter.setColor(Color.pink); painter.mlt(200); painter.paint(dot3); painter.moveToCenter(); painter.mrt( 200); painter.paint(dot3); painter.moveToCenter(); } /* This was a bit tricky, i wanted to make two circles with the same radius, but not the same color. So I made one object and colored it two different colors. */ private void painterGreenAndOrangeCircle(SPainter painter, SCircle dot4) { //Green small circles painter.setColor(Color.GREEN); painter.mlt(200); painter.mbk( 200); painter.paint(dot4); painter.moveToCenter(); painter.mrt(200); painter.mbk(200); painter.paint(dot4); painter.moveToCenter(); //orange small circles painter.setColor(Color.orange); painter.mlt(200); painter.mfd( 200); painter.paint(dot4); painter.moveToCenter(); painter.mrt(200); painter.mfd(200); painter.paint(dot4); painter.moveToCenter(); } // i made sure to keep the painter invariant through out the program(just a note) //the rest is simple infrastructure public Dots(){ paintTheImage(); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run () { new Dots(); } }); } }