summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/model/StoneTray.java
diff options
context:
space:
mode:
authorJannis Harder <harder@informatik.uni-luebeck.de>2011-05-02 04:46:00 +0200
committerJannis Harder <harder@informatik.uni-luebeck.de>2011-05-02 04:46:00 +0200
commit1e7cdb33f5bfce2d3fb174abd778788108557078 (patch)
tree7ef56ce60b813402eabff2bc1aee77ba6142cbd8 /src/jrummikub/model/StoneTray.java
parent91b921248f4a74bddd8434bcad65c45fd8486549 (diff)
downloadJRummikub-1e7cdb33f5bfce2d3fb174abd778788108557078.tar
JRummikub-1e7cdb33f5bfce2d3fb174abd778788108557078.zip
More javadocs for the model
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@64 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/model/StoneTray.java')
-rw-r--r--src/jrummikub/model/StoneTray.java22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/jrummikub/model/StoneTray.java b/src/jrummikub/model/StoneTray.java
index 0d48bf5..07719cf 100644
--- a/src/jrummikub/model/StoneTray.java
+++ b/src/jrummikub/model/StoneTray.java
@@ -9,6 +9,9 @@ import jrummikub.util.Pair;
/**
* A StoneTray is a collection of positioned objects (for example {@link Stone}s
* or {@link StoneSet}s.
+ *
+ * @param <E>
+ * Type of positioned objects (must implement Sizeable)
*/
public class StoneTray<E extends Sizeable> implements
Iterable<Pair<E, Position>> {
@@ -20,12 +23,12 @@ public class StoneTray<E extends Sizeable> implements
LEFT, RIGHT, TOP, BOTTOM;
}
-
/**
* Removes object from tray and returns it
*
* @param position
* position of the object that will be removed
+ * @return the picked up stone
*/
public E pickUp(Position position) {
for (Pair<E, Position> i : objects) {
@@ -69,8 +72,8 @@ public class StoneTray<E extends Sizeable> implements
for (Pair<E, Position> i : objects) {
Position currentPosition = i.getSecond();
E currentObject = i.getFirst();
- if (!objectsOverlap(object, position,
- currentObject, currentPosition)) {
+ if (!objectsOverlap(object, position, currentObject,
+ currentPosition)) {
continue;
}
// Object would be placed inside the current object
@@ -113,12 +116,10 @@ public class StoneTray<E extends Sizeable> implements
if (position1.getY() + object1.getHeight() <= position2.getY()) {
return false;
}
- if (position1.getX() >= position2.getX()
- + object2.getWidth()) {
+ if (position1.getX() >= position2.getX() + object2.getWidth()) {
return false;
}
- if (position1.getY() >= position2.getY()
- + object2.getHeight()) {
+ if (position1.getY() >= position2.getY() + object2.getHeight()) {
return false;
}
return true;
@@ -169,6 +170,13 @@ public class StoneTray<E extends Sizeable> implements
return overlapX > overlapY;
}
+ /**
+ * Returns the position of an object that is already on the tray
+ *
+ * @param object
+ * object whose position is requested
+ * @return position of the object or null when the object is not on the tray
+ */
public Position getPosition(E object) {
for (Pair<E, Position> i : objects) {
if (object.equals(i.getFirst())) {