Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package boardGame;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.List;
- import java.util.Random;
- import javax.swing.ImageIcon;
- public class Dice extends Board{
- private static int diceRoll;
- private static Random rand = new Random();
- static final ImageIcon diceRolling = new ImageIcon(Dice.class.getResource("dice.gif"));
- static final Dice one = new Dice(1, new ImageIcon(Dice.class.getResource("dice1.png")));
- static final Dice two = new Dice(2, new ImageIcon(Dice.class.getResource("dice2.png")));
- static final Dice three = new Dice(3, new ImageIcon(Dice.class.getResource("dice3.png")));
- static final Dice four = new Dice(4, new ImageIcon(Dice.class.getResource("dice4.png")));
- static final Dice five = new Dice(5, new ImageIcon(Dice.class.getResource("dice5.png")));
- static final Dice six = new Dice(6, new ImageIcon(Dice.class.getResource("dice6.png")));
- static List dices = Arrays.asList(one, two, three, four, five, six);
- ImageIcon img;
- Dice dice;
- public Dice(int s, ImageIcon img) {
- super(s);
- s = diceRoll;
- this.img = img;
- }
- public void rollDice(){
- dice = (Dice) dices.get(rand.nextInt(dices.size())+1);
- diceRoll = dices.indexOf(dice);
- setSpace(diceRoll + getSpace());
- }
- public static int getDiceRoll() {
- return diceRoll;
- }
- public ImageIcon getImageIcon() {
- return img;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement