lundi 20 avril 2015

Picking and displaying data randomly from an array

I created an array with 100 elements in it and I am wondering how I can randomly select an element in the array and display the result that is contained within.

import java.util.ArrayList;
import java.util.Random;

public class slotMachine {

Symbol[] slot1, slot2,slot3;

public slotMachine() {
    // TODO Auto-generated constructor stub
//Generate a random element and state what it is

}



public void initSlots(){
    int i;
//Slot 1
slot1 = new Symbol[100];
for(i = 0; i < 30;i++){
    slot1[i] = Symbol.Bar;
}
for (; i < 60; i++){    
slot1[i] = Symbol.Cherry;
}
for (; i < 80; i++){    
    slot1[i] = Symbol.Lime;
    }
for (; i < 100; i++){   
    slot1[i] = Symbol.Seven;
    }




Aucun commentaire:

Enregistrer un commentaire