|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jrummikub.model.StoneTray<E>
E
- Type of positioned objects (must implement Sizeable)public class StoneTray<E extends Sizeable>
A StoneTray is a collection of positioned objects (for example Stone
s
or StoneSet
s.
Nested Class Summary | |
---|---|
protected static class |
StoneTray.Direction
Possible move directions in case of overlapping Stones/Sets |
Field Summary | |
---|---|
protected java.util.HashMap<E,Pair<E,Position>> |
objects
|
Constructor Summary | |
---|---|
StoneTray()
|
Method Summary | |
---|---|
IStoneTray<E> |
clone()
Create a clone of the StoneTray |
void |
drop(E object,
Position position)
Adds object to the tray |
protected Pair<Position,StoneTray.Direction> |
fixInvalidDrop(E object,
Position pos,
StoneTray.Direction dir)
Checks whether the object may be placed on the given position, computes new position if not |
Position |
getPosition(E object)
Returns the position of an object that is already on the tray |
int |
getSize()
Return the number of objects on the tray |
java.util.Iterator<Pair<E,Position>> |
iterator()
|
boolean |
pickUp(E object)
Tries to pick up (remove) a given object |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.HashMap<E extends Sizeable,Pair<E extends Sizeable,Position>> objects
Constructor Detail |
---|
public StoneTray()
Method Detail |
---|
public void drop(E object, Position position)
IStoneTray
drop
in interface IStoneTray<E extends Sizeable>
object
- object to add to Handposition
- Position
to put the objectprotected Pair<Position,StoneTray.Direction> fixInvalidDrop(E object, Position pos, StoneTray.Direction dir)
object
- to be droppeddir
- pos
- the object is dropped at
public Position getPosition(E object)
IStoneTray
getPosition
in interface IStoneTray<E extends Sizeable>
object
- object whose position is requested
public java.util.Iterator<Pair<E,Position>> iterator()
iterator
in interface java.lang.Iterable<Pair<E extends Sizeable,Position>>
public boolean pickUp(E object)
IStoneTray
pickUp
in interface IStoneTray<E extends Sizeable>
object
- object to pick up
public IStoneTray<E> clone()
IStoneTray
clone
in interface IStoneTray<E extends Sizeable>
clone
in class java.lang.Object
public int getSize()
IStoneTray
getSize
in interface IStoneTray<E extends Sizeable>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |