Interpreter1.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 Interpreter1 {
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) {
18                   command = "exit";
19               }// user clicked on Cancel
20               if (command.equalsIgnoreCase("blue")) {
21                   miro.setColor(Color.BLUE);
22                   miro.paint(dot);
23               } else if (command.equalsIgnoreCase("red")) {
24                   miro.setColor(Color.RED);
25                   miro.paint(dot);
26               } else if (command.equalsIgnoreCase("help")) {
27                   JOptionPane.showMessageDialog(null, "Valid command are:" + "RED|Blue|Help|Exit");
28               } else if (command.equalsIgnoreCase("exit")) {
29                   miro.end();
30                   System.out.println("Thank you for viewing the dots....");
31                   break;
32               } else {
33                   JOptionPane.showMessageDialog(null, "Unrecognizable command" + "command.toUpperCase");
34               }
35           }
36       }
37   
38       public  Interpreter1 (){
39           interpreter();}
40   
41       public static void main(String[] args) {
42           SwingUtilities.invokeLater(new Runnable() {
43               public void run() {
44                   new Interpreter1();
45   
46               }
47           });
48       }
49   }
50