?
2011-02-03 20:30:05 UTC
public void randomBook() {
setAllBooksToNotRead();
int i;
book s;
boolean check=true;
while(check){
i = rand.nextInt(BookList.length);
if(BookList[i].getAlreadyread()==true){
check=false;
i = rand.nextInt(BookList.length);
}
System.out.println(BookList[i].getTitle());
BookList[i].setAlreadyread(true);
}
}
I am trying to make a program that randomly returns the titles of books without repeating them until the whole array has been "read". Assume that my instance fields are correct for the purposes of this question. I am stuck at this point, I am a beginner when it comes to java so I won't understand anything more than a simple array. My idea is that when a number is randomly called it should be removed from the array but I don't know how to do that.
thanks