feat: added inventory method to get inventory as array

This commit is contained in:
Yannik Bretschneider 2021-06-01 00:31:50 +02:00
parent bccffad8f0
commit 20f014209a

View File

@ -80,6 +80,16 @@ public class Inventory implements Iterable<StoneType> {
content.remove(stone);
}
/** Returns the stones inside of the Inventory as Array of {@link StoneType StoneTypes} */
public StoneType[] getStonesAsArray() {
var toReturn = new StoneType[content.size()];
var iterator = content.iterator();
for (int i = 0; i < content.size(); i++) {
toReturn[i] = iterator.next();
}
return toReturn;
}
/** Iterates over the inventory. */
@Override
public Iterator<StoneType> iterator() {