public static void decode(Question decodedQuestion, String encodedQuestion) throws DecodeException {
        if (encodedQuestion.charAt(0) == '<') {
            int i = 1;
            while (encodedQuestion.charAt(i) != '>') {
                i++;
            }
            if (i > 1) {
                decodedQuestion.setID(Integer.valueOf(encodedQuestion.substring(1, i)));
            } else {
                decodedQuestion.setID(-1);
            }

            i++;
            int beginning = i;
            if (encodedQuestion.substring(i, i + 3).compareTo("<$<") == 0) {
                while (encodedQuestion.substring(i, i + 3).compareTo(">$>") != 0) {
                    i++;
                }
                if (beginning < i - 1) {
                    decodedQuestion.setText(encodedQuestion.substring(beginning + 3, i));
                } else {
                    decodedQuestion.setText(null);
                }
                i += 3;

                beginning = i;
                if (encodedQuestion.charAt(0) == '<') {
                    while (encodedQuestion.charAt(i) != '>') {
                        i++;
                    }
                    if (i - 1 > beginning) {
                        decodedQuestion.setDifficulty(Integer.valueOf(encodedQuestion.substring(beginning + 1, i)));
                    } else {
                        decodedQuestion.setDifficulty(0);
                    }
                    i++;
                    encodedQuestion = encodedQuestion.substring(i); //do not remove this line
                } else {
                    throw new DecodeException();
                }
            } else {
                throw new DecodeException();
            }
        } else {
            throw new DecodeException();
        }
    }