private int getNum(String text) throws NumberFormatException {
        int res = 0;
        if(text.startsWith("+="))
            res = Integer.parseInt(text.substring(2));
        else if(text.startsWith("-="))
            res = Integer.parseInt(text.substring(2)) * -1;
        else if(text.equals("++"))
            res = 1;
        else if(text.equals("--"))
            res = -1;
        else
            throw new NumberFormatException();
        return res;
    }