Interpreter1.java
1    package interpreters;
2    /* 
3     *This interpreter is intended to paint different colored dots in a wuindow 
4     */
5    import java.awt.Color;
6    import javax.swing.JOptionPane;
7    import javax.swing.SwingUtilities;
8    import painter.SPainter;
9    import shapes.SCircle;
10   public class Interpreter1 {
11       private void interpreter() {
12           //Create objects to think with
13           SPainter miro = new SPainter("Dot Thing", 400, 400);
14           miro.setScreenLocation(0,0);
15           SCircle dot = new SCircle(180);
16   
17           //Repeatedly take a command from an input dialog box and interpret it
18           while (true){
19               String command = JOptionPane.showInputDialog(null, "Command?");
20               if(command == null){command = "exit";} //user clicked on cancel
21               if(command.equalsIgnoreCase("blue")){
22                   miro.setColor(Color.BLUE);
23                   miro.paint(dot);
24               }
25               else if(command.equalsIgnoreCase("red")){
26                   miro.setColor(Color.RED);
27                   miro.paint(dot);
28               }
29               else if(command.equalsIgnoreCase("help")){
30                   JOptionPane.showMessageDialog(null, "Valid commands are: " + "RED | BLUE | HELP | EXIT ");
31               }
32               else if(command.equalsIgnoreCase("exit")){
33                   miro.end();
34                   System.out.println("Thank you for viewing the dots...");
35                   break;
36               }
37               else {
38                   JOptionPane.showMessageDialog(null, "Unrecognizable command: ");
39               }
40           }
41       }
42   
43       //Simple painting
44       public Interpreter1(){
45           interpreter();
46       }
47   
48       public static void main(String[] args){
49           SwingUtilities.invokeLater(new Runnable(){
50               public void run(){
51                   new Interpreter1();
52               }
53           });
54   
55   
56       }
57   
58   }
59