Interpreter3.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 Interpreter3 {
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               }
34   
35   
36               else if (command.equalsIgnoreCase("exit")){
37                   miro.end();
38                   System.out.println("thankyou for viewing the dots...");
39                   break;
40   
41               } else{
42                   JOptionPane.showMessageDialog(null,"unrecognizable command:"+ command.toUpperCase());
43               }
44           }
45   
46       }
47   
48   
49   
50       public Interpreter3(){
51           interpreter();
52       }
53       public static void main(String[] args) {
54           SwingUtilities.invokeLater(new Runnable() {
55               @Override
56               public void run() {
57                   new Interpreter3();
58               }
59           });
60       }
61   }
62   
63