satorialist 3581c1489c finished 12a_5 7 年 前
..
12a_4 3581c1489c finished 12a_5 7 年 前
12a_5 3581c1489c finished 12a_5 7 年 前
Aufgabenblatt12_Collections.pdf c537f6c4c5 added new assignment 7 年 前
README.md 3581c1489c finished 12a_5 7 年 前

README.md

12a_collections

12a_4

datastructures

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.

"shuffle" methods
  • Collections.shuffle(Collection) to shuffle a Collection
  • implement a custom shuffle algorithm

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;

}

12a_5

datastructures

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