@@ -0,0 +1,2340 @@
+package gamecontrollers.checks;%0A%0Aimport models.board.Direction;%0Aimport models.board.Space;%0Aimport models.board.TileComponent;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Iterator;%0Aimport java.util.List;%0A%0A/**%0A * Created by kevinnieman on 4/21/14.%0A */%0Apublic class WouldTileComponentBeOnBoard %7B%0A    private List%3CTileComponent%3E visitedTiles;%0A%0A    public WouldTileComponentBeOnBoard()%7B%0A        visitedTiles = new ArrayList%3CTileComponent%3E();%0A    %7D%0A%0A%0A    public boolean check(Space space, TileComponent tile)%7B%0A        //clear any old calculations%0A        visitedTiles.clear();%0A%0A        //innocent until proven guilty%0A        boolean onBoard = true;%0A%0A        //this tile has been visited so add it to the list of visited tiles%0A        visitedTiles.add(tile);%0A%0A        //you just moved off the board son, thats a big mistake buddy%0A        if(space == null)%0A            return false;%0A%0A        //need to check if the attached tileComponent has neighbors where the space doesnt%0A        //get a direciton iterator from the given tile%0A        Iterator%3CDirection%3E iterator = tile.getDirection().iterator();%0A%0A        //with this direction iterator iterate over the directions of the given tile%0A        while(iterator.hasNext())%7B%0A            //get the current direction%0A            Direction direction = iterator.next();%0A            //check if the tile has a conjoined tile in this direction%0A            if(tile.siblingExists(direction))%7B%0A                //tile has a conjoined tile in this direction%0A                //check if the space has a neighbor in this direction%0A                if(!space.hasAdjacentSpace(direction))%7B%0A                    //if the space doesnt have an adjacent space in this direction you are hanging over the board%0A                    return false;%0A                %7D%0A                else%7B%0A                    //here we know two things%0A                    //the space has a conjoined space in this direction%0A                    //the tile has a conjoined tile in this direction%0A                    //therefore continue to make the checks given that this tile has not been visited%0A                    if(!visitedTiles.contains(tile))%0A                        onBoard = onBoard && check(space.getAdjacentSpace(direction), tile.getConjoinedTile(direction));%0A                %7D%0A            %7D%0A        %7D%0A%0A        return onBoard;%0A    %7D%0A%7D%0A

Add check for going off board