Great help. Clone works well, but I wasn’t able to make arrayCopy work. I did patch together a way to get it to restart. But it only runs one more time, so something is amiss.
StringList fruits;
StringList clones;
String [] list = {"apple","orange","grape","banana","lemon"};
String [] clonedList = list.clone();
String item;
int i;
int x;
void setup(){
size(300,300);
fruits = new StringList(list);
clones = new StringList(clonedList);
textAlign(CENTER);
fill(255);
background(0);
}
void randomSelect(){
textSize(60);
print("list(" + fruits.size() + ") ");
println(list);
print("clonedList(" + clones.size() + ") ");
println(clonedList);
int x = int(random(fruits.size()));
item = fruits.get(x);
println("Name Removed: " + item);
fill(255,0,0);
text(item, width/2,height/2);
fruits.remove(x);
String[] newList = fruits.array();
list = newList;
print("(" + fruits.size() + ") ");
println(list);
println();
}
void mouseClicked(){
background(0);
if(fruits.size() > 0){
randomSelect();
}else if(fruits.size() == 0){
gameOver();
list = clonedList;
fruits = clones;
}else if(list == clonedList){
randomSelect();
}
}
void gameOver(){
background(0);
textSize(35);
fill(0,0,255);
text("Out of Names", width/2,height/2);
}
void draw(){
}