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