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