feat: added inventory method to get inventory as array
This commit is contained in:
parent
bccffad8f0
commit
20f014209a
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user