private int apply(char op, int a, int b) {
        switch (op) {
            case '+': return b + a;
            case '-': return b - a;
            case '*': return b * a;
            case '/': return b / a;
        }
        return 0;
    }