1 package Interpreters; 2 3 import java.awt.*; 4 import javax.swing.JOptionPane; 5 import javax.swing.SwingUtilities; 6 import painter.SPainter; 7 import shapes.SCircle; 8 9 public class Interpreter1 { 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 } 23 else if(command.equalsIgnoreCase("red")){ 24 why.setColor(Color.red); 25 why.paint(d); 26 } 27 else if(command.equalsIgnoreCase("help")){ 28 JOptionPane.showMessageDialog(null, "Valid comments are Red|Blue|Help|Exit"); 29 } 30 else if(command.equalsIgnoreCase("exit")){ 31 System.out.println("Thanks you for view le dots"); 32 why.end(); 33 break; 34 } 35 else{ 36 JOptionPane.showMessageDialog(null, "That is not a command, I would suggest trying the 'help' command" +command.toUpperCase()); 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 53