Interperter1.java
1    // Commands are BLUE: RED: HELP: EXIT:
2    
3    package interpreters;
4    
5    
6    import javax.swing.JOptionPane;
7    import javax.swing.SwingUtilities;
8    import painter.SPainter;
9    import shapes.SCircle;
10   import java.awt.Color;
11   
12   
13   
14   
15   public class Interperter1 {
16       private void interperter() {
17           // creating an object to think with
18           SPainter miro = new SPainter("Dot Thing", 400, 400);
19           miro.setScreenLocation(0, 0);
20           SCircle dot = new SCircle(180);
21   
22           while (true) {
23               String command = JOptionPane.showInputDialog(null, "Command?");
24               if (command == null) {
25                   command = "exit";
26               }
27               if (command.equalsIgnoreCase("blue")) {
28                   miro.setColor(Color.BLUE);
29                   miro.paint(dot);
30               } else if (command.equalsIgnoreCase("red")) {
31                   miro.setColor(Color.RED);
32                   miro.paint(dot);
33               } else if (command.equalsIgnoreCase("help")) {
34                   JOptionPane.showMessageDialog(null, "Valid commands are:" + "RED | BLUE | HELP | EXIT");
35               } else if (command.equalsIgnoreCase("exit")) {
36                   miro.end();
37                   System.out.println("Thank you for viewing the dots . . .");
38                   break;
39               } else {
40                   JOptionPane.showMessageDialog(null, "Unrecognized Command: " + command.toUpperCase());
41               }
42           }
43   
44           }
45           public Interperter1(){
46               interperter();
47           }
48   
49   
50           public static void main(String[] args) {
51               SwingUtilities.invokeLater(new Runnable() {
52                   public void run() {
53                       new Interperter1();
54                   }
55               });
56           }
57   
58   
59   }
60