import java.util.*;

/**
 * A bad implementation of a FractionAddingMachine.
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class FractionAddingMachineBad
{
    /**
     * Evaluate an expression.
     *
     * @param expression   A String representation of an expression
     * @return             The result of evaluating the expression
     */
    public String evaluate(String expression)
    {
        Operand              left, right;
        String               leftToken, operator, rightToken;       
        StringTokenizer      st;
       
        // Construct a StringTokenizer that uses the operator(s)
        // as delimiters
        st    = new StringTokenizer(expression, "+");

        // Tokenize the expression (which, in the current version, must
        // involve the + operator
        leftToken  = st.nextToken();
        rightToken = st.nextToken();

        // Create the left side operand
        left   = new Fraction();

        // Initialize the left side operand
        left.fromString(leftToken);

        // Create the right side operand
        right  = new Fraction();

        // Initialize the right side operand
        right.fromString(rightToken);

        // Perform the operation
        left.increaseBy(right);

        // Return the result
        return left.toString();       
    }
}
