package interpreters;; import java.awt.Color; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import painter.SPainter; import shapes.SCircle; public class intepreter3 { private static Color randomColor(){ int rv = (int)(Math.random()*256); int gv = (int)(Math.random()*256); int bv = (int)(Math.random()*256); return new Color(rv,gv,bv); } private void intepreters(){ SPainter miro = new SPainter("Dot Things", 400, 400); miro.setScreenLocation(0,0); SCircle dot = new SCircle(180); while (true){ String command = JOptionPane.showInputDialog(null,"Command?"); if (command.equalsIgnoreCase("blue")){ miro.setColor(Color.blue); miro.paint(dot); }if (command.equalsIgnoreCase("green")) { miro.setColor(Color.green); miro.paint(dot); }if (command.equalsIgnoreCase("yellow")) { miro.setColor(Color.yellow); miro.paint(dot); }if(command.equalsIgnoreCase("red")) { miro.setColor(Color.red); miro.paint(dot); } else if(command.equalsIgnoreCase("help")){ JOptionPane.showInputDialog(null,"Valid commands are:"+" Help|Red|Blue|random"); } else if (command.equalsIgnoreCase("random")){ miro.setColor(randomColor()); miro.paint(dot); }else if (command.equalsIgnoreCase("exit")){ miro.end(); System.out.println("Thank you for viewing Dots...."); break; }if(command == null){command = "exit";} else{ JOptionPane.showMessageDialog(null,"Unrecognizable command: "+ command.toUpperCase()); } } } public intepreter3(){ intepreters(); } public static void main(String[]args){ SwingUtilities.invokeLater(new Runnable(){ public void run(){ new intepreter3(); } }); } }