Advertisement
Guest User

Untitled

a guest
May 28th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. List <String> diceColorsList = new ArrayList<String>(Arrays.asList("red", "blue", "green", "yellow", "white"));
  2.  
  3.    public String rollDiceColor(){
  4.         Random rand = new Random();
  5.         if (diceColorsList.size() > 0) {
  6.             int n = rand.nextInt(diceColorsList.size());
  7.             String str = diceColorsList.get(n);
  8.             diceColorsList.remove(n);
  9.             return str;
  10.         } else {
  11.             return "0";
  12.         }
  13.     }
  14.  
  15.     public int rollDiceNumber(){
  16.         Random rand = new Random();
  17.         int n = rand.nextInt(3)+1;
  18.         return n;
  19.     }
  20.  
  21.     public void resetDice(){
  22.         diceColorsList = new ArrayList<String>(Arrays.asList("red", "blue", "green", "yellow", "white"));
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement