Hello, I've written a multiple choice question version of a Hangman game. Everything works 'except' I don't want questions asked more than once. I've come up with a search algorithm, but I obviously don't have it correct, or I'm going wrong somewhere, It compiles but the questions still repeat. here's what I have so far: Any help or advice would be greatly appreciated.
questionNum = (int)(Math.random() * 10);
while (isUsed)
{
searchResult = seqSearch(usedList, questionNum);
if (searchResult == -1)
{
isUsed = false;
}//end if
else
questionNum = (int)(Math.random() * 10);
usedList.addElement(questionNum);
}//end while
QuestionInfo curQues = new QuestionInfo(questionObj[questionNum]);
displayQuestion(questionObj, curQues, questionNum);
public int seqSearch(Vector<Integer> usedList, int questionNum)
{
boolean found = false;
for (Integer num : usedList)
if (num == questionNum)
{
found = true;
break;
}
if (found)
return 1;
else
return -1;
}