|
7 anos atrás | |
---|---|---|
.. | ||
card | 7 anos atrás | |
game | 7 anos atrás | |
Main.java | 7 anos atrás | |
README.md | 7 anos atrás | |
screen1.jpg | 7 anos atrás |
two datastructures were chosen: ArrayList and Stack
The Players are held by an ArrayList, as I wanted to be able to dynamically extend the datastructure with entries, while still being able to iterate and access the structure like an array.
The Cards are held by a Stack. Now, just like I would stack cards on top of each other with a real, physical deck of cards, I want my datastructure to work like a LAST IN FIRST OUT queue. Whenever, someone draws a card, they have to draw the topmost card on the deck. That's our Stack.
Random random = new Random(); for (int i = array.length - 1; i > 0; i--) {
index = random.nextInt(i + 1);
temp = array[index];
array[index] = array[i];
array[i] = temp;
}