import java.applet.Applet;
import java.awt.Button;
import java.awt.Frame;
import java.awt.Toolkit;
import java.math.BigDecimal;
import java.math.BigInteger;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class Prog {

  final static boolean _debug = false;
  Frame hallo;

  /* This line has to be added to every class that wants to communicate to MuPAD!!! */
  public native static String calcMuPAD(String query);

	//*******************************************************************
	//* A test if object returning works correctly...                   *
	//*******************************************************************
  /*
  public static Frame returnFrame(String name) {
		Frame testFrame = new Frame(name);
		testFrame.addNotify();
  	return testFrame;
  }
  */

  public static void testForNull(Object test) {
    if (test == null)
      JOptionPane.showMessageDialog(null, "Object was NULL", "NULL-test", JOptionPane.PLAIN_MESSAGE);
    else
      JOptionPane.showMessageDialog(null, "Object was NOT NULL:" + test.getClass().toString(), "NULL-test", JOptionPane.PLAIN_MESSAGE);
  }

  public static int getToolColors() {
    Toolkit.getDefaultToolkit().beep();
    return Toolkit.getDefaultToolkit().getMaximumCursorColors();
  }

  public static int getToolColorModel() {
    return Toolkit.getDefaultToolkit().getColorModel().getNumColorComponents();
  }

  public static int getToolPixelSize() {
    return Toolkit.getDefaultToolkit().getColorModel().getPixelSize();
  }


  public static int getToolScreenSize() {
    Toolkit.getDefaultToolkit().beep();
    return Toolkit.getDefaultToolkit().getScreenResolution();
  }

  public static int NullPException() throws NullPointerException {
    throw new NullPointerException("What a terrible Exception...");
    //return 2;
  }

  public Applet returnOnlyApplet() {

    return new Applet();
  }

  public static void showJPane(String name) {
    JOptionPane.showMessageDialog(null, name, name, JOptionPane.PLAIN_MESSAGE);
  }

  public String getAppletName(Applet applet) {
    JOptionPane.showMessageDialog(null, "I am in getAppletname", "...", JOptionPane.INFORMATION_MESSAGE);
    String testme = applet.getName();
    JOptionPane.showMessageDialog(null, "got: " + testme, "Test...", JOptionPane.INFORMATION_MESSAGE);
    return "Hallo";
  }

  public String getNull(Applet applet) {
    JOptionPane.showMessageDialog(null, "getAppletInfo will return NULL !", "In getNull", JOptionPane.INFORMATION_MESSAGE);
    return applet.getAppletInfo();
  }


  public String getFrameName(Frame frame) {

    Button jb = new Button("Hallo");
    Button jb2 = new Button("Hallo2");

    frame.add(jb);
    frame.add(jb2);
    frame.pack();
    frame.show();

    JOptionPane.showMessageDialog(null, "I am in getFramename", "...", JOptionPane.INFORMATION_MESSAGE);
    String testme = frame.getName();
    JOptionPane.showMessageDialog(null, "got: " + testme, "Test...", JOptionPane.INFORMATION_MESSAGE);
    return "Hallo";
  }


  public String getObjectName(Object object) {
    return object.toString();
  }

  public String getObjecttoString(Object object) {
    return object.getClass().toString();
  }


 public Frame returnOnlyFrame() {
    Frame testFrame = new Frame("testme");
    return testFrame;
    //return new Frame();
  }

 public JFrame returnOnlyJFrame() {
    //Frame testFrame = new Frame("testme");
    //return testFrame;
    return new JFrame();
  }

  /*
  public static void runApplet(String name) {
  	try {
			Class x = Class.forName(name);
			Applet myApplet = (Applet) x.newInstance();
			myApplet.init();
			myApplet.start();
			JOptionPane.showMessageDialog(null, "Now it should be available...", "Got from Java...", JOptionPane.INFORMATION_MESSAGE);
		} catch (ClassNotFoundException e) {
			JOptionPane.showMessageDialog(null, "Error! Could not find " + name + ".class", "Got from Java...", JOptionPane.ERROR_MESSAGE);
    } catch (InstantiationException e) {
			JOptionPane.showMessageDialog(null, "Error! Could not instantiate " + name + ".class", "Got from Java...", JOptionPane.ERROR_MESSAGE);
    } catch (IllegalAccessException e) {
			JOptionPane.showMessageDialog(null, "Error! Could not access " + name + ".class", "Got from Java...", JOptionPane.ERROR_MESSAGE);
		}
  }
  */


	//*******************************************************************
	//* A test if the callback works correctly...                       *
	//*******************************************************************

  /**
   * This is a native callback method that can send computations to MuPAD
   * Allow only one question at a time !!! (Static)
   */
  public static int callBack(String[] args) {
    //JOptionPane.showMessageDialog(null, "Now it goes...", "Press the button.", JOptionPane.INFORMATION_MESSAGE);
    String test = calcMuPAD("6*7");
    //int test = Integer.parseInt(calcMuPAD("6*7"));
    JOptionPane.showMessageDialog(null, "Result: " + test, "Got from MuPAD...", JOptionPane.INFORMATION_MESSAGE);
    //return calcMuPAD(query);
    return 42;
  }


  public static String callbackTest() {
    String query = JOptionPane.showInputDialog("Enter a calculation (a String will be the result):");
    String result = calcMuPAD(query);
    JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + result, "callbackTest", JOptionPane.INFORMATION_MESSAGE);
    return result;
  }


	//*******************************************************************
	//* System.exit test                                                *
	//*******************************************************************
  public static int systemExit() {
		JOptionPane.showMessageDialog(null, "Now the JVM is going down... ", "Prepare...", JOptionPane.INFORMATION_MESSAGE);
		System.exit(0);
		return 42;
  }


	//*******************************************************************
	//* tests that are not supposed to work (because of the name)...    *
	//*******************************************************************
  public static int key() {
   return 42;
  }

  public static int allEntries() {
  	return 42;
  }

  //*******************************************************************
	//* Constructor tests...                                            *
	//*******************************************************************

	public Prog() {
	 System.out.println("Constructor");
  }

  Prog(int j) {
   System.out.println("Constructor " + j);
  }

	//*******************************************************************
	//* This part is for testing the different array methods...         *
	//*******************************************************************
	public static int[][][][][] returnQuintArrayInteger() {

		int i5[][][][][] = {{ {{ {1,2}, {3,4} } , { {5,6}, {7,8}, {42,8788} }} , {{ {1,2}, {3,4} } , { {5,6}, {7,8}, {42,8788} }} }, { {{ {1,2}, {3,4} } , { {5,6}, {7,8}, {42,8788} }} , {{ {1,2}, {3,4} } , { {5,6}, {7,8}, {42,8788} }} }};
		return i5;
	}

	public static int[][][][] returnQuadArrayInteger() {

		int i3[][][][] = { {{ {1,2}, {3,4} } , { {5,6}, {7,8}, {42,8788} }} , {{ {1,2}, {3,4} } , { {5,6}, {7,8}, {42,8788} }} };
		return i3;
	}

	public static int[][][] returnTripleArrayInteger() {

		int i3[][][] = { { {1,2}, {3,4} } , { {5,6}, {7,8}, {42,8788} } };
		return i3;
	}

	public static int[][] returnDoubleArrayInteger() {

		int i3[][] = { {1, 2, 3}, {42, 43, 8788} } ;
		return i3;
	}

	public static int[] returnSingleArrayInteger() {

		int i3[] = { 1, 2, 3, 8788, 42 } ;
		return i3;
	}

	//**************************************************************************************
	//* This part is for testing the different single array methods with handing arrays... *
	//**************************************************************************************

	public static boolean returnBooleanFromSingleArrayBoolean(boolean[] retValue, boolean show) {
		if (show) {
		  String list = "";
			for (int i=0; i < retValue.length; i++) {
		  	list += "[i:"+ i + "] = " + String.valueOf(retValue[i]) + '\n';
			}
		  JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnBooleanFromSingleArrayBoolean", JOptionPane.INFORMATION_MESSAGE);
	  }
  	return true;
	}

	public static char returnCharFromSingleArrayChar(char[] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			list += "[i:"+ i + "] = " + String.valueOf(retValue[i]) + '\n';
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnCharFromSingleArrayChar", JOptionPane.INFORMATION_MESSAGE);
		return 'J';
	}

	public static byte returnByteFromSingleArrayByte(byte[] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			list += "[i:"+ i + "] = " + String.valueOf(retValue[i]) + '\n';
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnByteFromSingleArrayByte", JOptionPane.INFORMATION_MESSAGE);
		return 42;
	}

	public static short returnShortFromSingleArrayShort(short[] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			list += "[i:"+ i + "] = " + String.valueOf(retValue[i]) + '\n';
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnShortFromSingleArrayShort", JOptionPane.INFORMATION_MESSAGE);
		return 42;
	}

	public static int returnIntFromSingleArrayInt(int[] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			list += "[i:"+ i + "] = " + String.valueOf(retValue[i]) + '\n';
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnIntFromSingleArrayInteger", JOptionPane.INFORMATION_MESSAGE);
		return 42;
	}

	public static long returnLongFromSingleArrayLong(long[] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			list += "[i:"+ i + "] = " + String.valueOf(retValue[i]) + '\n';
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnLongFromSingleArrayLong", JOptionPane.INFORMATION_MESSAGE);
		return 42;
	}

	public static float returnFloatFromSingleArrayFloat(float[] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			list += "[i:"+ i + "] = " + String.valueOf(retValue[i]) + '\n';
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnFloatFromSingleArrayFloat", JOptionPane.INFORMATION_MESSAGE);
		return (float)42.24;
	}

	public static double returnDoubleFromSingleArrayDouble(double[] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			list += "[i:"+ i + "] = " + String.valueOf(retValue[i]) + '\n';
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnDoubleFromSingleArrayDouble", JOptionPane.INFORMATION_MESSAGE);
		return 42.24;
	}

	public static String returnStringFromSingleArrayString(String[] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			list += "[i:"+ i + "] = " + String.valueOf(retValue[i]) + '\n';
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnStringFromSingleArrayString", JOptionPane.INFORMATION_MESSAGE);
		return "return from returnStringFromSingleArrayString";
	}

	public static BigInteger returnBigIntegerFromSingleArrayBigInteger(BigInteger[] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			list += "[i:"+ i + "] = " + String.valueOf(retValue[i]) + '\n';
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnBigIntegerFromSingleArrayBigInteger", JOptionPane.INFORMATION_MESSAGE);
		return BigInteger.ONE;
	}

	public static BigDecimal returnBigDecimalFromSingleArrayBigDecimal(BigDecimal[] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			list += "[i:"+ i + "] = " + String.valueOf(retValue[i]) + '\n';
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnBigDecimalFromSingleArrayBigDecimal", JOptionPane.INFORMATION_MESSAGE);
		return retValue[0];
	}

	//**************************************************************************************
	//* This part is for testing the different double array methods with handing arrays... *
	//**************************************************************************************

	public static boolean returnBooleanFromDoubleArrayBoolean(boolean[][] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			for (int j = 0; j < retValue[i].length; j++) {
				list += "[i:"+ i +"][j:"+ j +"] = " + String.valueOf(retValue[i][j]) + '\n';
			}
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnBooleanFromDoubleArrayBoolean", JOptionPane.INFORMATION_MESSAGE);
		return true;
	}

	public static char returnCharFromDoubleArrayChar(char[][] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			for (int j = 0; j < retValue[i].length; j++) {
				list += "[i:"+ i +"][j:"+ j +"] = " + String.valueOf(retValue[i][j]) + '\n';
			}
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnCharFromDoubleArrayChar", JOptionPane.INFORMATION_MESSAGE);
		return 'J';
	}

	public static byte returnByteFromDoubleArrayByte(byte[][] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			for (int j = 0; j < retValue[i].length; j++) {
				list += "[i:"+ i +"][j:"+ j +"] = " + String.valueOf(retValue[i][j]) + '\n';
			}
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnByteFromDoubleArrayByte", JOptionPane.INFORMATION_MESSAGE);
		return 'J';
	}

	public static short returnShortFromDoubleArrayShort(short[][] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			for (int j = 0; j < retValue[i].length; j++) {
				list += "[i:"+ i +"][j:"+ j +"] = " + String.valueOf(retValue[i][j]) + '\n';
			}
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnShortFromDoubleArrayShort", JOptionPane.INFORMATION_MESSAGE);
		return 42;
	}

	public static int returnIntFromDoubleArrayInt(int[][] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			for (int j = 0; j < retValue[i].length; j++) {
				list += "[i:"+ i +"][j:"+ j +"] = " + String.valueOf(retValue[i][j]) + '\n';
			}
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnIntFromDoubleArrayInt", JOptionPane.INFORMATION_MESSAGE);
		return 42;
	}

	public static long returnLongFromDoubleArrayLong(long[][] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			for (int j = 0; j < retValue[i].length; j++) {
				list += "[i:"+ i +"][j:"+ j +"] = " + String.valueOf(retValue[i][j]) + '\n';
			}
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnLongFromDoubleArrayLong", JOptionPane.INFORMATION_MESSAGE);
		return 42;
	}

	public static float returnFloatFromDoubleArrayFloat(float[][] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			for (int j = 0; j < retValue[i].length; j++) {
				list += "[i:"+ i +"][j:"+ j +"] = " + String.valueOf(retValue[i][j]) + '\n';
			}
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnFloatFromDoubleArrayFloat", JOptionPane.INFORMATION_MESSAGE);
		return (float)42.42;
	}

	public static double returnDoubleFromDoubleArrayDouble(double[][] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			for (int j = 0; j < retValue[i].length; j++) {
				list += "[i:"+ i +"][j:"+ j +"] = " + String.valueOf(retValue[i][j]) + '\n';
			}
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnDoubleFromDoubleArrayDouble", JOptionPane.INFORMATION_MESSAGE);
		return 42.42;
	}

	public static BigInteger returnBigIntegerFromDoubleArrayBigInteger(BigInteger[][] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			for (int j = 0; j < retValue[i].length; j++) {
				list += "[i:"+ i +"][j:"+ j +"] = " + String.valueOf(retValue[i][j]) + '\n';
			}
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnBigIntegerFromDoubleArrayBigInteger", JOptionPane.INFORMATION_MESSAGE);
		return BigInteger.ONE;
	}

	public static BigDecimal returnBigDecimalFromDoubleArrayBigDecimal(BigDecimal[][] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			for (int j = 0; j < retValue[i].length; j++) {
				list += "[i:"+ i +"][j:"+ j +"] = " + String.valueOf(retValue[i][j]) + '\n';
			}
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnBigDecimalFromDoubleArrayBigDecimal", JOptionPane.INFORMATION_MESSAGE);
		return retValue[0][0];
	}

	public static String returnStringFromDoubleArrayString(String[][] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			for (int j = 0; j < retValue[i].length; j++) {
				list += "[i:"+ i +"][j:"+ j +"] = " + String.valueOf(retValue[i][j]) + '\n';
			}
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnStringFromDoubleArrayString", JOptionPane.INFORMATION_MESSAGE);
		return "return from returnStringFromDoubleArrayString";
	}

	//**************************************************************************************
	//* This part is for testing some triple array methods with handing arrays...          *
	//**************************************************************************************

	public static boolean returnBooleanFromTripleArrayBoolean(boolean[][][] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			for (int j = 0; j < retValue[i].length; j++) {
				for (int k = 0; k < retValue[i][j].length; k++) {
				  list += "[i:"+ i +"][j:"+ j +"][j:"+ k +"] = " + String.valueOf(retValue[i][j][k]) + '\n';
			  }
			}
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnBooleanFromTripleArrayBoolean", JOptionPane.INFORMATION_MESSAGE);
		return true;
	}

	public static char returnCharFromTripleArrayChar(char[][][] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			for (int j = 0; j < retValue[i].length; j++) {
				for (int k = 0; k < retValue[i][j].length; k++) {
					list += "[i:"+ i +"][j:"+ j +"][j:"+ k +"] = " + String.valueOf(retValue[i][j][k]) + '\n';
				}
			}
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: \n" + list, "returnCharFromTripleArrayChar", JOptionPane.INFORMATION_MESSAGE);
		return 'J';
	}

	//*******************************************************************
	//* Non-Primitive tests non-static                                  *
	//*******************************************************************/

	/* Big Integer tests ***********************************************/
	public BigInteger[] returnSingleArrayBigInteger() {
		BigInteger[] bi = {BigInteger.ONE, BigInteger.ZERO };
		return bi;
	}

	public BigInteger[] returnSingleArrayBigInteger(BigInteger[] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			list += retValue[i].toString() + '\n';
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: " + list, "ArrayBigInteger", JOptionPane.INFORMATION_MESSAGE);
		return retValue;
	}

	/* Big Integer tests ***********************************************/
	public BigDecimal[] returnSingleArrayBigDecimal() {
		BigDecimal[] bd = { new BigDecimal(6200.55), new BigDecimal(8788.21) };
		String list = "";
		for (int i=0; i < bd.length; i++) {
			list += bd[i].toString() + '\n';
		}

		return bd;
	}

	public BigDecimal[] returnSingleArrayBigDecimal(BigDecimal[] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			list += retValue[i].toString() + '\n';
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: " + list, "ArrayBigDecimal", JOptionPane.INFORMATION_MESSAGE);
		return retValue;
	}


	//*******************************************************************
	//* Primitive tests non-static                                      *
	//*******************************************************************

	/* Boolean tests ***************************************************/
	public boolean[] returnSingleArrayBoolean() {
		boolean[] b = {true, false};
		return b;
	}

	public boolean[] returnSingleArrayBoolean(boolean[] retValue) {
		String list = retValue.toString();
		JOptionPane.showMessageDialog(null, "Got from MuPAD: " + list, "ArrayBoolean", JOptionPane.INFORMATION_MESSAGE);
		return retValue;
	}

	/* Byte tests ******************************************************/
	public byte[] returnSingleArrayByte() {
		byte b[] = {0, Byte.MAX_VALUE};
		JOptionPane.showMessageDialog(null, "Going to return: [0, 127]", "ArrayByte", JOptionPane.INFORMATION_MESSAGE);
		return b;
	}

	public byte[] returnSingleArrayByte(byte[] retValue) {
		String list = retValue.toString();
		JOptionPane.showMessageDialog(null, "Got from MuPAD: " + list, "ArrayByte", JOptionPane.INFORMATION_MESSAGE);
		return retValue;
	}

	/* Char tests ******************************************************/
	public char[] returnSingleArrayChar() {
		char c[] = {'J', 'F'};
		JOptionPane.showMessageDialog(null, "Going to return: [J, F]", "ArrayChar", JOptionPane.INFORMATION_MESSAGE);
		return c;
	}

	public char[] returnSingleArrayChar(char[] retValue) {
		String list = retValue.toString();
		JOptionPane.showMessageDialog(null, "Got from MuPAD: " + list, "ArrayChar", JOptionPane.INFORMATION_MESSAGE);
		return retValue;
	}

	/* Short tests *****************************************************/
	public short[] returnSingleArrayShort() {
		short s[] = {0, Short.MAX_VALUE};
		JOptionPane.showMessageDialog(null, "Going to return: " + s.toString(), "ArrayShort", JOptionPane.INFORMATION_MESSAGE);
		return s;
	}

	public short[] returnSingleArrayShort(short[] retValue) {
		String list = retValue.toString();
		JOptionPane.showMessageDialog(null, "Got from MuPAD: " + list, "ArrayShort", JOptionPane.INFORMATION_MESSAGE);
		return retValue;
	}

	/* Integer tests ***************************************************/
	public int[] returnSingleArrayInt() {
		int i[] = {0, Integer.MAX_VALUE};
		JOptionPane.showMessageDialog(null, "Going to return: " + i.toString(), "ArrayInteger", JOptionPane.INFORMATION_MESSAGE);
		return i;
	}

	public int[] returnSingleArrayInt(int[] retValue) {
		String list = retValue.toString();
		JOptionPane.showMessageDialog(null, "Got from MuPAD: " + list, "ArrayInteger", JOptionPane.INFORMATION_MESSAGE);
		return retValue;
	}

	/* Long tests ******************************************************/
	public long[] returnSingleArrayLong() {
		long l[] = {0, Long.MAX_VALUE};
		JOptionPane.showMessageDialog(null, "Going to return: " + l.toString(), "ArrayLong", JOptionPane.INFORMATION_MESSAGE);
		return l;
	}

	public long[] returnSingleArrayLong(long[] retValue) {
		String list = retValue.toString();
		JOptionPane.showMessageDialog(null, "Got from MuPAD: " + list, "ArrayLong", JOptionPane.INFORMATION_MESSAGE);
		return retValue;
	}

	/* Float tests *****************************************************/
	public float[] returnSingleArrayFloat() {
		float f[] = {0, Float.MAX_VALUE};
		JOptionPane.showMessageDialog(null, "Going to return: " + f.toString(), "ArrayFloat", JOptionPane.INFORMATION_MESSAGE);
		return f;
	}

	public float[] returnSingleArrayFloat(float[] retValue) {
		String list = retValue.toString();
		JOptionPane.showMessageDialog(null, "Got from MuPAD: " + list, "ArrayFloat", JOptionPane.INFORMATION_MESSAGE);
		return retValue;
	}

	/* Double tests ****************************************************/
	public double[] returnSingleArrayDouble() {
		double[] d = {0.0, Double.MAX_VALUE};
		JOptionPane.showMessageDialog(null, "Going to return: " + d.toString(), "ArrayDouble", JOptionPane.INFORMATION_MESSAGE);
		return d;
	}

	public double[] returnSingleArrayDouble(double[] retValue) {
		String list = retValue.toString();
		JOptionPane.showMessageDialog(null, "Got from MuPAD: " + list, "ArrayDouble", JOptionPane.INFORMATION_MESSAGE);
		return retValue;
	}

	/* String tests ****************************************************/
	public String[] returnSingleArrayString() {
		String[] retValue = {"Hello","MuPAD-World"};
		return retValue;
	}

	public String[] returnSingleArrayString(String[] retValue) {
		String list = "";
		for (int i=0; i < retValue.length; i++) {
			list += retValue[i].toString() + '\n';
		}
		JOptionPane.showMessageDialog(null, "Got from MuPAD: " + list, "Double", JOptionPane.INFORMATION_MESSAGE);
		return retValue;
	}



	//*******************************************************************
	//* This part is for testing the different matching methods...      *
	//*******************************************************************

	public static int numberIntTest(byte retValue, boolean show) {
		if (show) {
			JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "numberIntTest (byte)", JOptionPane.INFORMATION_MESSAGE);
		}
		return retValue;
	}

	public static int numberIntTest(short retValue, boolean show) {
		if (show) {
			JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "numberIntTest (short)", JOptionPane.INFORMATION_MESSAGE);
		}
		return retValue;
	}

	public static int numberIntTest(int retValue, boolean show) {
		if (show) {
			JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "numberIntTest (int)", JOptionPane.INFORMATION_MESSAGE);
		}
			return retValue;
		}

	public static long numberTest(byte retValue, boolean show) {
		if (show) {
			JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "numberTest (byte)", JOptionPane.INFORMATION_MESSAGE);
		}
		return retValue;
	}

	public static long numberTest(short retValue, boolean show) {
		if (show) {
    	JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "numberTest (short)", JOptionPane.INFORMATION_MESSAGE);
		}
    return retValue;
	}

	public static long numberTest(int retValue, boolean show) {
		if (show) {
    	JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "numberTest (int)", JOptionPane.INFORMATION_MESSAGE);
		}
    return retValue;
	}

	public static long numberTest(long retValue, boolean show) {
		if (show) {
			JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "numberTest (long)", JOptionPane.INFORMATION_MESSAGE);
		}
		return retValue;
	}

	public static BigInteger numberTest(BigInteger retValue, boolean show) {
		if (show) {
			JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "numberTest (BigInteger)", JOptionPane.INFORMATION_MESSAGE);
		}
		return retValue;
	}

	public static double numberTest(float retValue, boolean show) {
		if (show) {
			JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "numberTest (float)", JOptionPane.INFORMATION_MESSAGE);
		}
		return retValue;
	}

	public static double numberTest(double retValue, boolean show) {
		if (show) {
			JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "numberTest (double)", JOptionPane.INFORMATION_MESSAGE);
		}
		return retValue;
	}

	public static BigDecimal numberTest(BigDecimal retValue, boolean show) {
		if (show) {
	  	JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "numberTest (BigDecimal)", JOptionPane.INFORMATION_MESSAGE);
		}
	  return retValue;
  }

  //*******************************************************************
  //* Non-Primitive tests non-static                                  *
  //*******************************************************************/

  /* Big Integer tests ***********************************************/
  public BigInteger returnBigInteger() {
    return BigInteger.ONE;
  }

  public BigInteger returnBigInteger(BigInteger retValue) {
    JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "BigInteger", JOptionPane.INFORMATION_MESSAGE);
    return retValue;
  }

	/* Big Integer tests ***********************************************/
	public BigDecimal returnBigDecimal() {
		return new BigDecimal("9223372036854775808");
	}

	public BigDecimal returnBigDecimal(BigDecimal retValue) {
		JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "BigDecimal", JOptionPane.INFORMATION_MESSAGE);
		return retValue;
	}


	//*******************************************************************
	//* Primitive tests non-static                                      *
	//*******************************************************************

  /* Boolean tests ***************************************************/
  public boolean returnBoolean() {
    JOptionPane.showMessageDialog(null, "Going to return: true", "Boolean", JOptionPane.INFORMATION_MESSAGE);
    return true;
  }

  public boolean returnBoolean(boolean retValue) {
    JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "Boolean", JOptionPane.INFORMATION_MESSAGE);
    return retValue;
  }

  /* Byte tests ******************************************************/
  public byte returnByte() {
    JOptionPane.showMessageDialog(null, "Going to return: " + Byte.MAX_VALUE, "Byte", JOptionPane.INFORMATION_MESSAGE);
    return Byte.MAX_VALUE;
  }

  public byte returnByte(byte retValue) {
    JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "Byte", JOptionPane.INFORMATION_MESSAGE);
    //return (byte)(retValue + 1);
		return retValue;
  }

  /* Char tests ******************************************************/
  public char returnChar() {
    return 'J';
  }

  public char returnChar(char retValue) {
    JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "Char", JOptionPane.INFORMATION_MESSAGE);
    return retValue;
  }

  /* Short tests *****************************************************/
  public short returnShort() {
    JOptionPane.showMessageDialog(null, "Going to return: " + Short.MAX_VALUE, "Short", JOptionPane.INFORMATION_MESSAGE);
    return Short.MAX_VALUE;
  }

  public short returnShort(short retValue) {
    JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "Short", JOptionPane.INFORMATION_MESSAGE);
    //return (short)(retValue + 1);
		return retValue;
  }

  /* Integer tests ***************************************************/
	public int returnInt() {
    JOptionPane.showMessageDialog(null, "Going to return: " + Integer.MAX_VALUE, "Integer", JOptionPane.INFORMATION_MESSAGE);
	  return Integer.MAX_VALUE;
  }

  public int returnInt(int retValue) {
    JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "Integer", JOptionPane.INFORMATION_MESSAGE);
    return retValue;
  }

  /* Long tests ******************************************************/
  public long returnLong() {
    JOptionPane.showMessageDialog(null, "Going to return: " + Long.MAX_VALUE, "Long", JOptionPane.INFORMATION_MESSAGE);
    return Long.MAX_VALUE;
  }

  public long returnLong(long retValue) {
    JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "Long", JOptionPane.INFORMATION_MESSAGE);
    return retValue;
  }

  /* Float tests *****************************************************/
  public float returnFloat() {
    JOptionPane.showMessageDialog(null, "Going to return: " + Float.MAX_VALUE, "Float", JOptionPane.INFORMATION_MESSAGE);
    return Float.MAX_VALUE;
  }

  public float returnFloat(float retValue) {
    JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "Float", JOptionPane.INFORMATION_MESSAGE);
    return retValue;
  }

  /* Double tests ****************************************************/
  public double returnDouble() {
    JOptionPane.showMessageDialog(null, "Going to return: " + Double.MAX_VALUE, "Double", JOptionPane.INFORMATION_MESSAGE);
    return Double.MAX_VALUE;
  }

  public double returnDouble(double retValue) {
    JOptionPane.showMessageDialog(null, "Got from MuPAD: " + retValue, "Double", JOptionPane.INFORMATION_MESSAGE);
    return retValue;
  }

  /* String tests ****************************************************/
  public String returnString() {
    return "Hello MuPAD-world";
  }

  public String returnString(String testString) {
    return "Hello " + testString + "...";
  }

	//*******************************************************************
	//* Some other access specifiers                                    *
	//*******************************************************************
	void testSpecifier1() {
		JOptionPane.showMessageDialog(null, "testSpecifier1", "Hoho", JOptionPane.INFORMATION_MESSAGE);
	}

  protected void testSpecifier2() {
		JOptionPane.showMessageDialog(null, "testSpecifier2", "Hoho", JOptionPane.INFORMATION_MESSAGE);
  }

	private void testSpecifier3() {
		JOptionPane.showMessageDialog(null, "testSpecifier3", "Hoho", JOptionPane.INFORMATION_MESSAGE);
	}


  private static int privateReturnInt() {
    return 42;
  }

  public static String isJFrameArray(JFrame[] theFrames) {
    String str = "";
    for (int i = 0; i<theFrames.length; i++) {
      System.out.println("Frame " + i + " has the name: " + theFrames[i].getName());
      str += "Frame " + i + " has the name: " + theFrames[i].getName() + "\n";
    }
    return str;
  }

  public JFrame[] createJFrameArray(int size) {
    JFrame[] retJF = new JFrame[size];

    for (int i = 0; i<size; i++) {
      retJF[i] = new JFrame("Test" + i);
      retJF[i].setName("Test" + i);
    }

    return retJF;
  }



  public static void main(String args[]) {
    Toolkit.getDefaultToolkit().beep();
    /*
    JFrame a = new JFrame("This is a long test");
    a.setSize(200,100);
    a.show(true);
    a.toFront();
*/
/*
    String listOfNames = System.getProperties().toString();
    for (int i = 0; i < listOfNames; i++) {
      System.out.println(listOfNames[i]);
    }
*/
    //for (Enumeration el = System.getProperties().elements(); el.hasMoreElements(); ) {
    //  System.out.println((String)el.nextElement() + (String)el.nextElement().toString());
    //}

/*
    System.out.println(System.getProperties().toString());
    */
/*
    System.out.println("Byte.min = " + Byte.MIN_VALUE);
    System.out.println("Byte.max = " + Byte.MAX_VALUE);

    System.out.println("Short.min = " + Short.MIN_VALUE);
    System.out.println("Short.max = " + Short.MAX_VALUE);

    System.out.println("Integer.min = " + Integer.MIN_VALUE);
    System.out.println("Integer.max = " + Integer.MAX_VALUE);

    System.out.println("Long.min = " + Long.MIN_VALUE);
    System.out.println("Long.max = " + Long.MAX_VALUE);

    System.out.println("Float.min = " + Float.MIN_VALUE);
    System.out.println("Float.max = " + Float.MAX_VALUE);

    System.out.println("Double.min = " + Double.MIN_VALUE);
    System.out.println("Double.max = " + Double.MAX_VALUE);

    System.err.println("Test for System.err 1");
    System.err.println("Test for System.err 2");
*/
    //showJPane("Test");
    /*
    System.out.println("Now invoking some methods...");
    try {
      NullPException();
    }
    catch (Exception e) {
      throw new NullPointerException("This is a throw!");
    }
    Prog testp = new Prog();
    Frame fr = new Frame("Hello");
    String test = testp.getFrameName(fr);
    System.exit(0);
    System.out.println("returnBoolean:         " + testp.returnBoolean());
    System.out.println("returnByte:            " + testp.returnByte());
    System.out.println("returnChar:            " + testp.returnChar());
    System.out.println("returnShort:           " + testp.returnShort());
    System.out.println("returnInt:             " + testp.returnInt());
    System.out.println("returnLong:            " + testp.returnLong());
    System.out.println("returnFloat:           " + testp.returnFloat());
    System.out.println("returnDouble:          " + testp.returnDouble());
		System.out.println("returnBigInteger:      " + testp.returnBigInteger());
		System.out.println("returnBigDecimal:      " + testp.returnBigDecimal());
		System.out.println("-----------------------=======================");
		System.out.println("returnArrayBoolean:    " + testp.returnSingleArrayBoolean());
		System.out.println("returnArrayByte:       " + testp.returnSingleArrayByte());
		System.out.println("returnArrayChar:       " + testp.returnSingleArrayChar().toString());
		System.out.println("returnArrayShort:      " + testp.returnSingleArrayShort());
		System.out.println("returnArrayInt:        " + testp.returnSingleArrayInt());
		System.out.println("returnArrayLong:       " + testp.returnSingleArrayLong());
		System.out.println("returnArrayFloat:      " + testp.returnSingleArrayFloat());
		System.out.println("returnArrayDouble:     " + testp.returnSingleArrayDouble());
		System.out.println("returnArrayBigInteger: " + testp.returnSingleArrayBigInteger());
		System.out.println("returnArrayBigDecimal: " + testp.returnSingleArrayBigDecimal());
		System.out.println("-----------------------=======================");
		int[] testIntSingleArray = { 1,2 };
		int[][] testIntDoubleArray = { {2,4}, {3,5} };
		System.out.println("returnIntFromSingleArrayInteger: " + returnIntFromSingleArrayInt(testIntSingleArray));
		System.out.println("returnIntFromDoubleArrayInteger: " + returnIntFromDoubleArrayInt(testIntDoubleArray));
		*/
  }

	//*******************************************************************
	//* Variable tests..                                                *
	//*******************************************************************

	// Some privates...
	private char   pr_charVariable;
	private String pr_stringVariable;
	private byte   pr_byteVariable;
	private int    pr_intVariable;
	private short  pr_shortVariable;
	private long   pr_longVariable;
	private float  pr_floatVariable;
	private double pr_doubleVariable;

	//Some protected...
	protected char   po_charVariable;
	protected String po_stringVariable;
	protected byte   po_byteVariable;
	protected int    po_intVariable;
	protected short  po_shortVariable;
	protected long   po_longVariable;
	protected float  po_floatVariable;
	protected double po_doubleVariable;

	//Some package (friendly)...
	char   pa_charVariable;
	String pa_stringVariable;
	byte   pa_byteVariable;
	int    pa_intVariable;
	short  pa_shortVariable;
	long   pa_longVariable;
	float  pa_floatVariable;
	double pa_doubleVariable;

	// Some public...
	public char   pu_charVariable;
	public String pu_stringVariable;
	public byte   pu_byteVariable;
	public int    pu_intVariable;
	public short  pu_shortVariable;
	public long   pu_longVariable;
	public float  pu_floatVariable;
	public double pu_doubleVariable;

  // Some static...
	public static char  pu_satic_charVariable;
	protected static String po_static_stringVariable;
	private static double pr_static_doubleVariable;


}