Interpreter3.java
package interpreters;


import painter.SPainter;
import shapes.SCircle;
import javax.swing.*;
import java.awt.*;

public class Interpreter3 {
    private void interpreter() {
        // CREATE OBJECTS TO THINK WITH
        SPainter miro = new SPainter("Dot thing", 400, 400);
        miro.setScreenLocation(0, 0);
        SCircle dot = new SCircle(180);

        // REPEATEDLY TAKE A COMMAND FROM AN INPUT DIALOG BOX AND INTERPRET IT
        while(true) {
            String command = JOptionPane.showInputDialog(null, "command?");
            if (command == null) {
                command = "exit";
            } //user clicked on Cancel
            if (command.equalsIgnoreCase("blue")) {
                miro.setColor(Color.blue);
                miro.paint(dot);

            } else if (command.equalsIgnoreCase("red")) {
                miro.setColor(Color.red);
                miro.paint(dot);

            } else if (command.equalsIgnoreCase("green")) {
                miro.setColor(Color.green);
                miro.paint(dot);

            } else if (command.equalsIgnoreCase("yellow")) {
                miro.setColor(Color.yellow);
                miro.paint(dot);

            } else if (command.equalsIgnoreCase("random")){
                miro.setColor(randomColor());
                miro.paint(dot);

            } else if (command.equalsIgnoreCase("help")) {
                JOptionPane.showMessageDialog(null, "Valid commands are:"
                        + "Red | Blue |Green|Yellow| random | Help |Exit");
            } else if (command.equalsIgnoreCase("exit")) {
                miro.end();
                System.out.println("Thank you for viewing the dots ...");
                break;

            } else {
                JOptionPane.showMessageDialog(null, "Unrecognizable command:"
                        + command.toUpperCase());
            }


        }

    }

    private static Color randomColor() {
       int rv = (int) (Math.random()*256);
       int gv = (int) (Math.random()*256);
       int bv = (int) (Math.random()*256);
       return new Color (rv,gv,bv);
    }

    // INFRASTRUCTURE FOR SOME SIMPLE PAINTING

    public Interpreter3() {
        interpreter();
    }

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