|
před 7 roky | |
---|---|---|
.. | ||
12a_4 | před 7 roky | |
12a_5 | před 7 roky | |
Aufgabenblatt12_Collections.pdf | před 7 roky | |
README.md | před 7 roky |
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;
}
from the given datastructures (HashSet, TreeSet, LinkedList, ArrayList, HashMap, TreeMap), I chose to use ArrayList, as ArrayList is a simple datastructure, fitting for the job and performant