From f7f10a50afa6c1a1a0966d27526ee877556c8aa5 Mon Sep 17 00:00:00 2001 From: Ida Massow Date: Sat, 30 Apr 2011 13:44:17 +0200 Subject: Modelklassen angelegt, verschiedenen Stadien von fertig, StoneHeap fertig, getestet und kommentiert git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@19 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/model/GameState.java | 17 +++++++++++++++++ src/jrummikub/model/Hand.java | 15 +++++++++++++++ src/jrummikub/model/Player.java | 12 ++++++++++++ src/jrummikub/model/Stone.java | 2 ++ src/jrummikub/model/StoneHeap.java | 17 +++++++++++++++-- src/jrummikub/model/StoneSet.java | 18 ++++++++++++++++++ src/jrummikub/model/Table.java | 29 +++++++++++++++++++++++++++++ 7 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 src/jrummikub/model/GameState.java create mode 100644 src/jrummikub/model/Hand.java create mode 100644 src/jrummikub/model/Player.java create mode 100644 src/jrummikub/model/StoneSet.java create mode 100644 src/jrummikub/model/Table.java (limited to 'src/jrummikub') diff --git a/src/jrummikub/model/GameState.java b/src/jrummikub/model/GameState.java new file mode 100644 index 0000000..2e5f17b --- /dev/null +++ b/src/jrummikub/model/GameState.java @@ -0,0 +1,17 @@ +package jrummikub.model; + +public class GameState { + private Table table; + private Player[] players; + private int activePlayer; + private StoneHeap gameHeap; + + public void nextPlayer() { + + } + + public Player activePlayer() { + + } + +} diff --git a/src/jrummikub/model/Hand.java b/src/jrummikub/model/Hand.java new file mode 100644 index 0000000..91696ab --- /dev/null +++ b/src/jrummikub/model/Hand.java @@ -0,0 +1,15 @@ +package jrummikub.model; + +public class Hand { + private Stone[] stones; + private Position[] position; + + public Stone pickUp(Position position) { + + } + + public void drop(Stone stone, Position position) { + + } + +} diff --git a/src/jrummikub/model/Player.java b/src/jrummikub/model/Player.java new file mode 100644 index 0000000..7cc55be --- /dev/null +++ b/src/jrummikub/model/Player.java @@ -0,0 +1,12 @@ +package jrummikub.model; + +import java.awt.Color; + +public class Player { + private Hand hand; + // Könnten wir einfach die Steinfarben vergeben? + private Color color; + + // private String name; + +} diff --git a/src/jrummikub/model/Stone.java b/src/jrummikub/model/Stone.java index ee18a67..47354e5 100644 --- a/src/jrummikub/model/Stone.java +++ b/src/jrummikub/model/Stone.java @@ -1,9 +1,11 @@ package jrummikub.model; +/** */ public class Stone { private int value; private StoneColor color; private final boolean joker; + public Stone(int value, StoneColor color, boolean joker) { this.value = value; diff --git a/src/jrummikub/model/StoneHeap.java b/src/jrummikub/model/StoneHeap.java index bb6470e..f1f833d 100644 --- a/src/jrummikub/model/StoneHeap.java +++ b/src/jrummikub/model/StoneHeap.java @@ -5,10 +5,16 @@ import java.util.EnumSet; import java.util.List; import java.util.Random; +/** + * StoneHeap creates all {@link Stone}s for a game, manages them and allows + * players to draw one or more random Stones. + */ + public class StoneHeap { List heap; Random generator = new Random(); + /** Creates 106 Stones according to standard rules */ public StoneHeap() { heap = new ArrayList(); for (int i = 1; i <= 13; i++) { @@ -23,13 +29,20 @@ public class StoneHeap { heap.add(new Stone(0, StoneColor.ORANGE, true)); } + /** Removes random {@link Stone} from the heap and returns it */ public Stone drawStone() { return heap.remove(generator.nextInt(heap.size())); } - + + /** + * Removes several {@link Stone}s from the heap and returns them + * + * @param number + * number of requested Stones + */ public List drawStones(int number) { List drawnStones = new ArrayList(); - for (int i=0; i