summaryrefslogtreecommitdiffstats
path: root/src/jrummikub
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-04-28 15:45:30 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-04-28 15:45:30 +0200
commit10a338637d4e2c695ac4ab0e4d90719559e58888 (patch)
treedb35565da4d14548ec906ee8c77699e274525d71 /src/jrummikub
parentf572598766711056877aefcb95077139f2d83907 (diff)
downloadJRummikub-10a338637d4e2c695ac4ab0e4d90719559e58888.tar
JRummikub-10a338637d4e2c695ac4ab0e4d90719559e58888.zip
StoneHeap-Klasse (getestet und alles)
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@8 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub')
-rw-r--r--src/jrummikub/model/StoneHeap.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/jrummikub/model/StoneHeap.java b/src/jrummikub/model/StoneHeap.java
new file mode 100644
index 0000000..bb6470e
--- /dev/null
+++ b/src/jrummikub/model/StoneHeap.java
@@ -0,0 +1,37 @@
+package jrummikub.model;
+
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Random;
+
+public class StoneHeap {
+ List<Stone> heap;
+ Random generator = new Random();
+
+ public StoneHeap() {
+ heap = new ArrayList<Stone>();
+ for (int i = 1; i <= 13; i++) {
+ for (int j = 0; j < 2; j++) {
+ for (StoneColor c : EnumSet.allOf(StoneColor.class)) {
+ heap.add(new Stone(i, c, false));
+ }
+ }
+ }
+ // Joker
+ heap.add(new Stone(0, StoneColor.BLACK, true));
+ heap.add(new Stone(0, StoneColor.ORANGE, true));
+ }
+
+ public Stone drawStone() {
+ return heap.remove(generator.nextInt(heap.size()));
+ }
+
+ public List<Stone> drawStones(int number) {
+ List<Stone> drawnStones = new ArrayList<Stone>();
+ for (int i=0; i<number; i++){
+ drawnStones.add(drawStone());
+ }
+ return drawnStones;
+ }
+}