Arrays zu Listen geändert, StoneTray Klasse mit Sizeable Interface angelegt, Testklassen erzeugt

git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@26 72836036-5685-4462-b002-a69064685172
This commit is contained in:
Jannis Harder 2011-04-30 15:45:11 +02:00
parent 59e6d9c451
commit 0ef7834070
10 changed files with 80 additions and 60 deletions

View file

@ -3,7 +3,7 @@ package jrummikub.model;
/** Class managing the overall and momentary GameState */
public class GameState {
private Table table;
private Player[] players;
private List<Player> players;
private int activePlayer;
private StoneHeap gameHeap;

View file

@ -1,30 +1,6 @@
package jrummikub.model;
/** Class managing a {@link Player}'s {@link Stone}s */
public class Hand {
private Stone[] stones;
private Position[] position;
/**
* Removes {@link Stone} from Hand and returns it
*
* @param position
* position of {@link Stone} that will be removed
*/
public Stone pickUp(Position position) {
}
/**
* Adds {@link Stone} to the Hand
*
* @param stone
* {@link Stone} to add to Hand
* @param position
* {@link Position} to put the {@link Stone}
*/
public void drop(Stone stone, Position position) {
}
public class Hand extends StoneTray<Stone> {
}

View file

@ -0,0 +1,9 @@
package jrummikub.model;
/**
* Objects that have a size
*/
public interface Sizeable {
public float getWidth();
public float getHeight();
}

View file

@ -1,8 +1,10 @@
package jrummikub.model;
import jrummikub.util.Pair;
/** Class managing {@link Stone}s joined together to form sets */
public class StoneSet {
private Stone[] stones;
private List<Stone> stones;
/** Test for rule conflict within the StoneSet */
public boolean isValid() {
@ -16,7 +18,7 @@ public class StoneSet {
* @param position
* Splitting {@link Position}
*/
public StoneSet[] splitAt(int position) {
public Pair<StoneSet, StoneSet> splitAt(int position) {
}

View file

@ -0,0 +1,31 @@
package jrummikub.model;
/** A StoneTray is a collection of positioned objects (for example {@link Stone}s or {@link StoneSet}s. */
public abstract class StoneTray<E extends Sizeable> {
protected List<E> objects;
protected List<Position> positions;
/**
* Removes object from tray and returns it
*
* @param position
* position of the object that will be removed
*/
public E pickUp(Position position) {
}
/**
* Adds object to the tray
*
* @param object
* object to add to Hand
* @param position
* {@link Position} to put the object
*/
public void drop(E object, Position position) {
}
}

View file

@ -2,9 +2,7 @@ package jrummikub.model;
/** Class administering the {@link Stone}s on the game-Table */
public class Table {
private StoneSet[] sets;
private Position[] positions;
public class Table extends StoneTray<StoneSet> {
// Constructor
public Table gameTable = new Table();
@ -15,17 +13,7 @@ public class Table {
* @param position
* {@link Position} of the selected {@link Stone}
*/
public Stone pickUp(Position position) {
}
/**
* Removes a {@link StoneSet} from the Table and returns it
*
* @param position
* {@link Position} of the selected {@link StoneSet}
*/
public StoneSet pickUpSet(Position position) {
public Stone pickUpStone(Position position) {
}
@ -41,18 +29,6 @@ public class Table {
}
/**
* Adds {@link StoneSet} to Table
*
* @param position
* Specifies {@link Position} to put the {@link StoneSet}
* @param stones
* The {@link StoneSet} to add to the Table
*/
public void drop(Position position, StoneSet stones) {
}
/** Tests the Table for rule conflicts by checking all the {@link StoneSets} */
public boolean isValid() {

View file

@ -0,0 +1,24 @@
package jrummikub.util;
/**
* A pair of objects
*/
public class Pair<T1, T2> {
final T1 first;
final T2 second;
public Pair(T1 first, T2 second) {
this.first = first;
this.second = second;
}
public T1 getFirst() {
return first;
}
public T2 getSecond() {
return second;
}
}

View file

@ -1,5 +0,0 @@
package jrummikub.model;
public class PlayerTest {
}

View file

@ -1,5 +1,6 @@
package jrummikub.model;
public class HandTest {
public class StoneSetTest {
}

View file

@ -0,0 +1,6 @@
package jrummikub.model;
public class StoneTrayTest {
}