/// <summary> /// Mark the footprint of the given battleship location as occupied. /// </summary> /// <param name="location"> The location to mark the footprint of. </param> private void MarkFootprint(BattleshipLocation location) { foreach (var coord in location.IterateFootprint()) { Cells[coord.X, coord.Y] = location; } }
/// <summary> /// Check if the entire footprint of the given location is unoccupied. /// </summary> /// <param name="location"> The location to check the footprint of. </param> /// <returns> True if its footprint is clear, else false. </returns> private bool FootprintUnoccupied(BattleshipLocation location) { return(location.IterateFootprint() .All(coord => Cells[coord.X, coord.Y] == null)); }