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:
parent
59e6d9c451
commit
0ef7834070
10 changed files with 80 additions and 60 deletions
|
@ -3,7 +3,7 @@ package jrummikub.model;
|
||||||
/** Class managing the overall and momentary GameState */
|
/** Class managing the overall and momentary GameState */
|
||||||
public class GameState {
|
public class GameState {
|
||||||
private Table table;
|
private Table table;
|
||||||
private Player[] players;
|
private List<Player> players;
|
||||||
private int activePlayer;
|
private int activePlayer;
|
||||||
private StoneHeap gameHeap;
|
private StoneHeap gameHeap;
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,6 @@
|
||||||
package jrummikub.model;
|
package jrummikub.model;
|
||||||
|
|
||||||
/** Class managing a {@link Player}'s {@link Stone}s */
|
/** Class managing a {@link Player}'s {@link Stone}s */
|
||||||
public class Hand {
|
public class Hand extends StoneTray<Stone> {
|
||||||
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) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
9
src/jrummikub/model/Sizeable.java
Normal file
9
src/jrummikub/model/Sizeable.java
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
package jrummikub.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Objects that have a size
|
||||||
|
*/
|
||||||
|
public interface Sizeable {
|
||||||
|
public float getWidth();
|
||||||
|
public float getHeight();
|
||||||
|
}
|
|
@ -1,8 +1,10 @@
|
||||||
package jrummikub.model;
|
package jrummikub.model;
|
||||||
|
|
||||||
|
import jrummikub.util.Pair;
|
||||||
|
|
||||||
/** Class managing {@link Stone}s joined together to form sets */
|
/** Class managing {@link Stone}s joined together to form sets */
|
||||||
public class StoneSet {
|
public class StoneSet {
|
||||||
private Stone[] stones;
|
private List<Stone> stones;
|
||||||
|
|
||||||
/** Test for rule conflict within the StoneSet */
|
/** Test for rule conflict within the StoneSet */
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
|
@ -16,7 +18,7 @@ public class StoneSet {
|
||||||
* @param position
|
* @param position
|
||||||
* Splitting {@link Position}
|
* Splitting {@link Position}
|
||||||
*/
|
*/
|
||||||
public StoneSet[] splitAt(int position) {
|
public Pair<StoneSet, StoneSet> splitAt(int position) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
31
src/jrummikub/model/StoneTray.java
Normal file
31
src/jrummikub/model/StoneTray.java
Normal 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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,9 +2,7 @@ package jrummikub.model;
|
||||||
|
|
||||||
/** Class administering the {@link Stone}s on the game-Table */
|
/** Class administering the {@link Stone}s on the game-Table */
|
||||||
|
|
||||||
public class Table {
|
public class Table extends StoneTray<StoneSet> {
|
||||||
private StoneSet[] sets;
|
|
||||||
private Position[] positions;
|
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
public Table gameTable = new Table();
|
public Table gameTable = new Table();
|
||||||
|
@ -15,17 +13,7 @@ public class Table {
|
||||||
* @param position
|
* @param position
|
||||||
* {@link Position} of the selected {@link Stone}
|
* {@link Position} of the selected {@link Stone}
|
||||||
*/
|
*/
|
||||||
public Stone pickUp(Position position) {
|
public Stone pickUpStone(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) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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} */
|
/** Tests the Table for rule conflicts by checking all the {@link StoneSets} */
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
|
|
||||||
|
|
24
src/jrummikub/util/Pair.java
Normal file
24
src/jrummikub/util/Pair.java
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +0,0 @@
|
||||||
package jrummikub.model;
|
|
||||||
|
|
||||||
public class PlayerTest {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,5 +1,6 @@
|
||||||
package jrummikub.model;
|
package jrummikub.model;
|
||||||
|
|
||||||
public class HandTest {
|
|
||||||
|
public class StoneSetTest {
|
||||||
|
|
||||||
}
|
}
|
6
test/jrummikub/model/StoneTrayTest.java
Normal file
6
test/jrummikub/model/StoneTrayTest.java
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
package jrummikub.model;
|
||||||
|
|
||||||
|
|
||||||
|
public class StoneTrayTest {
|
||||||
|
|
||||||
|
}
|
Reference in a new issue