Interpreter1.java
1    package interpreters;
2    import java.awt.Color;
3    import javax.swing.SwingUtilities;
4    import painter.SPainter;
5    import shapes.SCircle;
6    import javax.swing.JOptionPane;
7    public class Interpreter1 {
8    
9    
10   private void Interpreter() {
11   
12       //create oblects to think with
13   
14       SPainter micro = new SPainter("Dot Thing",400,400);
15       micro.setScreenLocation(0,0);
16       SCircle dot = new SCircle(180);
17   
18       //repeatedly take a comand from an input dialog box and interpret it
19   
20       while (true) {
21   
22           String comand = JOptionPane.showInputDialog(null, "Comand?");
23           if (comand == null) {
24               comand = "exit";
25           } //user clicked on cancel
26   
27           if (comand.equalsIgnoreCase("blue")) {
28               micro.setColor(Color.blue);
29               micro.paint(dot);
30           } else if (comand.equalsIgnoreCase("red")) {
31               micro.setColor(Color.red);
32               micro.paint(dot);
33           } else if (comand.equalsIgnoreCase("help")) {
34   
35               JOptionPane.showMessageDialog(null, "vallid comands are:"
36                       + "RED / BLUE / HELP / EXIT ");
37   
38           } else if (comand.equalsIgnoreCase("exit")) {
39   
40   
41               micro.end();
42               System.out.println("Thank you for viewing the dots ...");
43               break;
44   
45   
46           } else {
47               JOptionPane.showMessageDialog(null, "Unrecognizqable comand:" + comand.toUpperCase());
48           }
49   
50   
51       }
52   
53   
54   
55   
56   
57   
58   
59   
60   
61   }
62   
63   
64   
65   //infastructure for painting
66   
67       public Interpreter1() {
68   
69         Interpreter();
70   
71   
72   
73   
74       }
75   
76   
77       public static void main(String[] args)  {
78           SwingUtilities.invokeLater(new Runnable() {
79               public void run() {
80                   new Interpreter1();
81               }
82   
83   
84           });
85       }
86   
87   
88   }
89