jeudi 3 octobre 2019

How to random an array so that a value should be printed x% at a time?

I am trying to make a simple slot machine in java. However I do not know how to randomize the array so that the a certain value of an array will return for x% at a time.

for example for the code below, I want to randomize the result given that Fish will return 40% , Dragon will return 30%, Joke will return 25% and Jackpot will return 5% at a time.

public class SlotMachine{
  public static void main(String args[]){
    String array[] = {"Fish", "Dragon", "Joker", "Jackpot"};


  }
}



Aucun commentaire:

Enregistrer un commentaire