package jrummikub.model; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import sun.reflect.generics.reflectiveObjects.NotImplementedException; import jrummikub.util.Pair; /** Class managing {@link Stone}s joined together to form sets */ public class StoneSet implements Iterable { private List stones; public StoneSet(Stone stone) { stones = Collections.singletonList(stone); } public StoneSet(List stones) { this.stones = new ArrayList(stones); } /** Test for rule conflict within the StoneSet */ public boolean isValid() { return false; } /** * Splits the StoneSet at a specified {@link Position} and returns two new * Stone Sets * * @param position * Splitting {@link Position} */ public Pair splitAt(int position) { //Exception falls falscher index if (position==0||position==stones.size()){ } else { } return null; } /** * Joins StoneSet to another StoneSet and returns the resulting new StoneSet * * @param other * StoneSet to be joined to active StoneSet */ public StoneSet join(StoneSet other) { return null; } public int size() { return stones.size(); } public Stone get(int i) { return stones.get(i); } @Override public Iterator iterator() { final Iterator it = stones.iterator(); return new Iterator(){ @Override public boolean hasNext() { return it.hasNext(); } @Override public Stone next() { return it.next(); } @Override public void remove() { // removing stones is impossible throw new NotImplementedException(); }}; } }