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    
8    public class Interpreter2 {
9        private void interpreter(){
10           SPainter miro = new SPainter("dot thing", 400,400);
11           miro.setScreenLocation(0,0);
12           SCircle dot = new SCircle(180);
13           while (true){
14               String command= JOptionPane.showInputDialog(null,"command?");
15               if (command == null) {command="exit";}
16               if(command.equalsIgnoreCase("blue")){
17                   miro.setColor(Color.blue);
18                   miro.paint(dot);
19               }
20               else if (command.equalsIgnoreCase("red")){
21                   miro.setColor(Color.red);
22                   miro.paint(dot);}
23                   else if (command.equalsIgnoreCase("green")){
24                       miro.setColor(Color.green);
25                       miro.paint(dot);
26               }
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 commands are:"+ "RED|BLUE|GREEN|YELLOW|HELP|EXIT");
32   
33               } else if (command.equalsIgnoreCase("exit")){
34                   miro.end();
35                   System.out.println("thankyou for viewing the dots...");
36                   break;
37   
38               } else{
39                   JOptionPane.showMessageDialog(null,"unrecognizable command:"+ command.toUpperCase());
40               }
41           }
42   
43       }
44       public Interpreter2(){
45           interpreter();
46       }
47       public static void main(String[] args) {
48           SwingUtilities.invokeLater(new Runnable() {
49               @Override
50               public void run() {
51                   new Interpreter2();
52               }
53           });
54       }
55   }
56   
57