/** * Returns the color of tiles in this collection if it is all one color, null otherwise; ignores WHITE tiles * * @return a <tt>Color</tt> object equal to those in this collection, or <tt>null</tt> if not all one color */ public Color?getColorIgnoreWhite() { TileCollection temp = new TileCollection(this); temp.removeTilesOfColor(Color.WHITE); return(temp.getColor()); }
/** * Adds the given tiles to this row, returning any overflow * * @param tc * the set of tiles to add * @return a TileCollection representing the overflow tiles (is an empty collection if no overflow) */ public TileCollection addTiles(TileCollection tc) { if (!tc.isAllOneColor()) { throw new ArgumentException("Invalid tile collection for build row: not all one color"); } if (tc.getColor() != color && color != null) // Shouldn't happen, check canAddTiles() first { return(tc); } color = tc.getColor(); count += tc.Count; int overflow = Math.Max(count - (row + 1), 0); // Can't have negative overflow count -= overflow; // 'overflow' extra tiles were added; remove them return(tc.drawTiles(overflow)); // Simplest way to get the appropriate TileCollection }