Interpreter2.java
1    package interpreters;
2    import java.awt.Color;
3    import javax.swing.JOptionPane;
4    import javax.swing.SwingUtilities;
5    import painter.SPainter;
6    import shapes.SCircle;
7    public class Interpreter2 {
8        private void interpreter() {
9            //Create Object To Think With
10           SPainter miro = new SPainter("Dot Thing", 400, 400);
11           miro.setScreenLocation(0, 0);
12           SCircle dot = new SCircle(180);
13   
14           // Repeatedly Take A Command From AN Input DiaLog Box Interpret it
15           while (true) {
16               String command = JOptionPane.showInputDialog(null, "Command?");
17               if ( command == null) {command = "exit";}// user clicked on Cancel
18               if ( command.equalsIgnoreCase("blue")) {
19                   miro.setColor(Color.BLUE);
20                   miro.paint(dot);
21               } else if (command.equalsIgnoreCase("red")) {
22                   miro.setColor(Color.RED);
23                   miro.paint(dot);
24               }else if (command.equalsIgnoreCase("green")) {
25                   miro.setColor(Color.GREEN);
26                   miro.paint(dot);
27               } else if (command.equalsIgnoreCase("yellow")) {
28                   miro.setColor(Color.YELLOW);
29                   miro.paint(dot);
30               } else if (command.equalsIgnoreCase("help")) {
31                   JOptionPane.showMessageDialog(null, "Valid command are:" + "RED|Blue|Green|Yellow|Help|Exit");
32               } else if (command.equalsIgnoreCase("exit")) {
33                   miro.end();
34                   System.out.println("Thank you for viewing the dots....");
35                   break;
36               } else {
37                   JOptionPane.showMessageDialog(null, "Unrecognizable command" + "command.toUpperCase");
38               }
39           }
40       }
41       //INFRASTRUCTURE FOR SOME SIMPLE PAINTING
42       public  Interpreter2 (){
43           interpreter();}
44   
45       public static void main(String[] args) {
46           SwingUtilities.invokeLater(new Runnable() {
47               public void run() {
48                   new Interpreter2();
49   
50               }
51           });
52       }
53   }
54   
55   
56