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
This commit is contained in:
Ida Massow 2011-04-30 13:44:17 +02:00
parent a601d484a2
commit f7f10a50af
7 changed files with 108 additions and 2 deletions

View file

@ -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() {
}
}

View file

@ -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) {
}
}

View file

@ -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;
}

View file

@ -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;

View file

@ -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<Stone> heap;
Random generator = new Random();
/** Creates 106 Stones according to standard rules */
public StoneHeap() {
heap = new ArrayList<Stone>();
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<Stone> drawStones(int number) {
List<Stone> drawnStones = new ArrayList<Stone>();
for (int i=0; i<number; i++){
for (int i = 0; i < number; i++) {
drawnStones.add(drawStone());
}
return drawnStones;

View file

@ -0,0 +1,18 @@
package jrummikub.model;
public class StoneSet {
private Stone[] stones;
public boolean isValid() {
}
public StoneSet[] splitAt(int position) {
}
public StoneSet join(StoneSet other) {
}
}

View file

@ -0,0 +1,29 @@
package jrummikub.model;
public class Table {
private StoneSet[] sets;
private Position[] positions;
// Constructor
public Table gameTable = new Table();
public Stone pickUp(Position position) {
}
public StoneSet pickUpSet(Position position) {
}
public StoneSet pickUpRange(Position from, Position to) {
}
public void drop(Position position, StoneSet stones) {
}
public boolean isValid() {
}
}