Invention1.java
package npw;

import painter.SPainter;
import shapes.SCircle;
import shapes.SSquare;

import javax.swing.*;
import java.awt.*;
;

public class Invention1 {
    public void paintTheImage() {
        SPainter painter = new SPainter("Circle of Square", 800, 800);
        SCircle circle = new SCircle(600);
        SSquare square = circle.inscribingSquare();
        paintCircle(painter, circle);
        paintSquares(painter, square);
    }

    private void paintCircle(SPainter painter, SCircle circle) {
        double shift = 0;
        Color color1 = Color.RED;
        Color color2 = Color.GREEN;
        while (shift < 600) {
            painter.paint(circle);
            circle.s2();
            if (shift % 2 == 1) {
                painter.setColor(color1);
            } else if (shift % 2 == 0) {
                painter.setColor(color2);
            }
            shift = shift + 15;
        }
    }

    private void paintSquares(SPainter painter, SSquare square) {
        double moved = 0;
        Color color3 = Color.BLUE;
        Color color4 = Color.YELLOW;
        while (moved < 200) {
            painter.draw(square);
            square.s2();
            if (moved % 2 == 1) {
                painter.setColor(color3);
            } else if (moved % 2 == 0) {
                painter.setColor(color4);
            }
            moved = moved + 15;
        }
    }

    public Invention1() {
        paintTheImage();
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new Invention1();
            }

        });
    }
}