Interpreter2.java
/* an extension of interpreter 1 
    this interpreter can read the following commands: 
    BLUE | RED | GREEN | YELLOW | HELP | EXIT 
 */



package interpreters;

import java.awt.Color;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import painter.SPainter;
import shapes.SCircle;

public class Interpreter2 {
    private void interpreter() {
        // objects to think with
        SPainter miro = new SPainter("Dot Thing", 400, 400);
        miro.setScreenLocation(0, 0);
        SCircle dot = new SCircle(180);

        // repeatedly take commands from imput box and interpret it
        while (true) {
            String command = JOptionPane.showInputDialog(null, "Command?");
            if (command == null) {
                command = "exit";
            }
            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("help")) {
                JOptionPane.showMessageDialog(null, "Valid Commands Are: " + "RED | BLUE | GREEN | YELLOW | 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());
            }
        }
    }

    // infastructure for simple painting
    public Interpreter2() {
        interpreter();
    }

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

    }
}