interpreter2.java
/* 
 * this interpreter is intended to paint different colored dots in a window. 
 * 
 * The commands that the interpreter can recognize and respond to are: 
 *  - BLUE: paint a blue dot 
 *  - RED: paint a red dot 
 *  - HELP: show a list of the commands in a dialog message box 
 *  - EXIT: terminate the program 
 */

package interpreters;

import painter.SPainter;
import shapes.SCircle;

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

public class interpreter2 {
    //*Step 0: Method call - Main method and the obj call, if there are particular objs you're gonna use.
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                new interpreter2();
            }
        });
    }

    //* Step 1: Remind what things you're gonna create, surely about your main class.

    private interpreter2() {

        //*Step 2: CREATE OBJECTS TO THINK WITH
        SPainter mirror = new SPainter("Dot Thing", 400, 400);
        mirror.setScreenLocation(0, 0);
        SCircle dot = new SCircle(180);

        //*Step 3: REPEATEDLY TAKE A COMMAND FROM AN INPUT DIALOG BOX AND INTERPRET IT
        while (true) {
            String command = JOptionPane.showInputDialog(null, "Command?");
            //* Selection 1
            if (command == null) {
                command = "exit";
            } // user clicked on Cancel
            //* Selection 2
            if (command.equalsIgnoreCase("BLUE")) {
                mirror.setColor(Color.BLUE);
                mirror.paint(dot);
            }
            //* Selection 3
            else if (command.equalsIgnoreCase("RED")) {
                mirror.setColor(Color.RED);
                mirror.paint(dot);
            }
            //* Selection 4
            else if (command.equalsIgnoreCase("Green")) {
                mirror.setColor(Color.green);
                mirror.paint(dot);
            }
            //* Selection 5
            else if (command.equalsIgnoreCase("Yellow")) {
                mirror.setColor(Color.YELLOW);
                mirror.paint(dot);
            }
            //* Selection 6
            else if (command.equalsIgnoreCase("HELP")) {
                JOptionPane.showMessageDialog(null, "Vaild commands are" + "BLUE|RED|GREEN|YELLOW|HELP|EXIT");
            }
            //* Selection 7
            else if (command.equalsIgnoreCase("EXIT")) {
                mirror.end();
                System.out.println("Thank you for viewing the dots ...");
                break;
            }
            //* This case: NOT DECIDE ANY given selection | All the other cases if not take any selection above
            else {
                JOptionPane.showMessageDialog(null, "Unrecognizable command: " + command.toUpperCase());
            }

        }
    }}