/home/ssingh6/NetBeansProjects/CS1/src/interpreters/Interpreter1.java
 1 /*
 2  * To change this license header, choose License Headers in Project Properties.
 3  * To change this template file, choose Tools | Templates
 4  * and open the template in the editor.
 5  */
 6 package interpreters;
 7 import javax.swing.JOptionPane;
 8 import java.awt.Color;
 9 import javax.swing.SwingUtilities;
10 import painter.SPainter;
11 import shapes.SCircle;
12 
13 /**
14  *
15  * @author ssingh6
16  */
17 public class Interpreter1 {
18     private void interpreter()
19     {
20         SPainter micro = new SPainter("Dot Thing",400,400);
21         micro.setScreenLocation(0,0);
22         SCircle dot = new SCircle(180);
23         while(true)
24         {
25             String command = JOptionPane.showInputDialog(null,"Command?");
26             if(command==null) { command="exit"; } // user clicked Cancel
27             if(command.equalsIgnoreCase("blue"))
28             {
29                 micro.setColor(Color.BLUE);
30                 micro.paint(dot);
31             }
32             else if(command.equalsIgnoreCase("red"))
33             {
34                 micro.setColor(Color.RED);
35                 micro.paint(dot);
36             }
37             else if(command.equalsIgnoreCase("help"))
38             {
39                 JOptionPane.showMessageDialog(null," Valid comments are :"+"RED|BLUE|HELP|EXIT");
40             }
41             else if(command.equalsIgnoreCase("exit"))
42             {
43                 micro.end();
44                 System.out.println("Thank You for viewing the dots...");
45                 break;
46                 
47             }
48             else
49             {
50                 JOptionPane.showMessageDialog(null, "Unrecognizable command:"+command.toUpperCase());
51             }
52         }
53     }
54 
55     
56     public Interpreter1()
57     {
58         interpreter();
59     }
60     public static void main(String[] args) {
61         SwingUtilities.invokeLater(new Runnable(){
62             public void run() {
63                 new Interpreter1();
64             }
65         });
66     }
67     
68 }
69 
70         
71