Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. package boardGame;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Arrays;
  5. import java.util.List;
  6. import java.util.Random;
  7.  
  8. import javax.swing.ImageIcon;
  9.  
  10. public class Dice extends Board{
  11.  
  12. private static int diceRoll;
  13. private static Random rand = new Random();
  14.  
  15. static final ImageIcon diceRolling = new ImageIcon(Dice.class.getResource("dice.gif"));
  16. static final Dice one = new Dice(1, new ImageIcon(Dice.class.getResource("dice1.png")));
  17. static final Dice two = new Dice(2, new ImageIcon(Dice.class.getResource("dice2.png")));
  18. static final Dice three = new Dice(3, new ImageIcon(Dice.class.getResource("dice3.png")));
  19. static final Dice four = new Dice(4, new ImageIcon(Dice.class.getResource("dice4.png")));
  20. static final Dice five = new Dice(5, new ImageIcon(Dice.class.getResource("dice5.png")));
  21. static final Dice six = new Dice(6, new ImageIcon(Dice.class.getResource("dice6.png")));
  22. static List dices = Arrays.asList(one, two, three, four, five, six);
  23. ImageIcon img;
  24. Dice dice;
  25.  
  26. public Dice(int s, ImageIcon img) {
  27. super(s);
  28. s = diceRoll;
  29. this.img = img;
  30. }
  31.  
  32. public void rollDice(){
  33. dice = (Dice) dices.get(rand.nextInt(dices.size())+1);
  34. diceRoll = dices.indexOf(dice);
  35. setSpace(diceRoll + getSpace());
  36. }
  37.  
  38. public static int getDiceRoll() {
  39. return diceRoll;
  40. }
  41.  
  42. public ImageIcon getImageIcon() {
  43. return img;
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement