I have an array of strings and I want to randomly choose each item which I have done below. However, what I'm having trouble with is once a random item has been selected, what are the ways I can delete the item once it has been selected?
For instance when I click on the app the letter "C" comes up and when I click again it randomly goes through each item. How do I once I click the second time get rid of item "C" so that it doesn't appear in my array after it has been viewed?
code below...
Code:
int lotteryLength = 37;
String[] lottery = {
"A", "B", "C", "D", "E",
"F", "G", "H", "I", "J",
"J", "K", "L", "M", "N",
"O", "P", "Q", "R", "S",
"T", "U", "V", "W", "X",
"Y", "Z",
"1", "2", "3", "4", "5",
"6", "7", "8", "9", "10",
};
PFont gotham;
int pointer = 0;
int rand;
boolean switcher = false;
void setup() {
size(200,200);
smooth();
gotham = loadFont("gotham.vlw");
textFont(gotham, 100);
}
void draw() {
background(103);
noStroke();
fill(0);
textAlign(CENTER);
if(switcher) {
pointer = rand;
text(lottery[pointer], width/2,height/2 + 36);
}
else {
text(lottery[pointer], width/2, height/2 + 36);
pointer = int(random(0, lotteryLength));
}
}
void mousePressed() {
rand = int(random(0, lotteryLength));
if(switcher) {
switcher = false;
//DELETE THIS TO NOT MAKE
//ITEMS IN ARRAY LOST
if(lotteryLength >= 0) {
lotteryLength--;
}
//END COMMENTARY
}
else {
switcher = true;
}
}