import java.util.Stack;

/**
 * A class for performing operations and transformations on terms in infix and postfix notation.
 */
public class Postfix {

	/**
	 * This method evaluates a term in postfix notation to its integer value.
	 *
	 * @param postfix
	 *            term in postfix notation
	 * @return integer value to which the postfix term evaluates
	 */
	public static int evalPostfix(String postfix) {
		// TODO: Code hier einfuegen.
	}

	/**
	 * This method transforms a term in infix notation to its representation in postfix notation.
	 *
	 * @param infix
	 *            term in infix notation
	 * @return term in postfix notation
	 */
	public static String infixToPostfix(String infix) {
		// TODO: Code hier einfuegen.
	}

	/**
	 * This method transforms a term in postfix notation to its representation in infix notation.
	 *
	 * @param postfix
	 *            term in postfix notation
	 * @return term in infix notation
	 */
	public static String postfixToInfix(String postfix) {
		// TODO: Code hier einfuegen.
	}

	/**
	 * Functions for testing methods {@link #evalPostfix(String) evalPostfix}, {@link #infixToPostfix(String) infixToPostfix}, and
	 * {@link #postfixToInfix(String) postfixToInfix}.
	 *
	 * @param args
	 */
	public static void main(String[] args) {
		String infix1 = "(3-(7*2))";
		String postfix1 = "372*-";
		int eval1 = -11;

		String infix2 = "((7+1)*((3-6)*(5-2)))";
		String postfix2 = "71+36-52-**";
		int eval2 = -72;

		System.out.println("             postfix1: " + postfix1);
		int n = evalPostfix(postfix1);
		System.out.println("evalPostfix(postfix1): " + n);
		if (n == eval1) {
			System.out.println("                       Korrekt!");
		} else {
			System.out.println("                       Nicht korrekt!");
		}
		System.out.println();

		System.out.println("                infix1: " + infix1);
		String s = infixToPostfix(infix1);
		System.out.println("infixToPostfix(infix1): " + s);
		if (s.equals(postfix1)) {
			System.out.println("                       Korrekt!");
		} else {
			System.out.println("                       Nicht korrekt!");
		}
		System.out.println();

		System.out.println("                postfix1: " + postfix1);
		s = postfixToInfix(postfix1);
		System.out.println("postfixToInfix(postfix1): " + s);
		if (s.equals(infix1)) {
			System.out.println("                       Korrekt!");
		} else {
			System.out.println("                       Nicht korrekt!");
		}
		System.out.println();

		System.out.println("             postfix2: " + postfix2);
		n = evalPostfix(postfix2);
		System.out.println("evalPostfix(postfix2): " + n);
		if (n == eval2) {
			System.out.println("                       Korrekt!");
		} else {
			System.out.println("                       Nicht korrekt!");
		}
		System.out.println();

		System.out.println("                infix2: " + infix2);
		s = infixToPostfix(infix2);
		System.out.println("infixToPostfix(infix2): " + s);
		if (s.equals(postfix2)) {
			System.out.println("                       Korrekt!");
		} else {
			System.out.println("                       Nicht korrekt!");
		}
		System.out.println();

		System.out.println("                postfix2: " + postfix2);
		s = postfixToInfix(postfix2);
		System.out.println("postfixToInfix(postfix2): " + s);
		if (s.equals(infix2)) {
			System.out.println("                       Korrekt!");
		} else {
			System.out.println("                       Nicht korrekt!");
		}
		System.out.println();
	}
}
