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 Interpreter2 { 10 private void interpreter() { 11 SPainter why = new SPainter("dot thingy majig", 400, 400); 12 why.setScreenLocation(0, 0); 13 SCircle d = new SCircle(180); 14 while (true) { 15 String command = JOptionPane.showInputDialog(null, "CoMmAnD"); 16 if (command == null) { 17 command = "exit"; 18 } 19 if (command.equalsIgnoreCase("blue")) { 20 why.setColor(Color.blue); 21 why.paint(d); 22 } else if (command.equalsIgnoreCase("red")) { 23 why.setColor(Color.red); 24 why.paint(d); 25 } 26 else if (command.equalsIgnoreCase("help")) { 27 JOptionPane.showMessageDialog(null, "Valid comments are Red|Blue|Green|Yellow|Help|Exit"); 28 } 29 else if (command.equalsIgnoreCase("green")) { 30 why.setColor(Color.green); 31 why.paint(d); 32 } 33 else if (command.equalsIgnoreCase("yellow")) { 34 why.setColor(Color.yellow); 35 why.paint(d); 36 } 37 else if (command.equalsIgnoreCase("exit")) { 38 System.out.println("Thanks you for view le dots"); 39 why.end(); 40 break; 41 } else { 42 JOptionPane.showMessageDialog(null, "That is not a command, I would suggest trying the 'help' command" + command.toUpperCase()); 43 } 44 } 45 } 46 47 public Interpreter2() { 48 interpreter(); 49 } 50 51 public static void main(String[] args) { 52 SwingUtilities.invokeLater(new Runnable() { 53 public void run() { 54 new Interpreter2(); 55 } 56 }); 57 } 58 59 } 60