<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,12 +1,14 @@
 package org.minesweeper;
 
-public class Cell {
+public final class Cell {
 	private final int row;
 	private final int column;
+	private final boolean isBomb;
 
-	public Cell(int row, int column) {
+	public Cell(int row, int column, boolean isBomb) {
 		this.row = row;
 		this.column = column;
+		this.isBomb = isBomb;
 	}
 
 	public int getRow() {
@@ -17,9 +19,10 @@ public class Cell {
 		return column;
 	}
 
+	
 	@Override
 	public String toString() {
-		return &quot;[&quot; + row + &quot;,&quot; + column + &quot;]&quot;;
+		return isBomb?&quot;*&quot;:&quot;.&quot;;
 	}
 
 	@Override
@@ -27,6 +30,7 @@ public class Cell {
 		final int prime = 31;
 		int result = 1;
 		result = prime * result + column;
+		result = prime * result + (isBomb ? 1231 : 1237);
 		result = prime * result + row;
 		return result;
 	}
@@ -39,12 +43,20 @@ public class Cell {
 			return false;
 		if (getClass() != obj.getClass())
 			return false;
-		Cell other = (Cell) obj;
+		final Cell other = (Cell) obj;
 		if (column != other.column)
 			return false;
+		if (isBomb != other.isBomb)
+			return false;
 		if (row != other.row)
 			return false;
 		return true;
 	}
 
+	public boolean isBomb() {
+		return isBomb;
+	} 
+	
+	
+
 }</diff>
      <filename>minesweeper_java/src/main/java/org/minesweeper/Cell.java</filename>
    </modified>
    <modified>
      <diff>@@ -5,50 +5,61 @@ import java.util.Set;
 
 public class Field {
 
-	private final String[][] field;
+	private final Cell[][] grid;
 
 	public Field(int rows, int cols) {
-		field = new String[rows][];
+		grid = new Cell[rows][];
 		for (int i = 0; i &lt; rows; i++) {
-			String[] row = new String[cols];
+			Cell[] row = new Cell[cols];
 			for (int j = 0; j &lt; cols; j++) {
-				row[j] = &quot;.&quot;;
+				row[j] = new Cell(i, j, false);
 			}
-			field[i] = row;
+			grid[i] = row;
 		}
 	}
 
-	public String cellAt(int row, int column) {
-		return field[row][column];
+	public Cell cellAt(int row, int column) {
+		return grid[row][column];
 	}
 
 	public void placeBombAt(int row, int column) {
-		field[row][column] = &quot;*&quot;;
+		grid[row][column] = new Cell(row, column, true);
 	}
 
 	public Set&lt;Cell&gt; getNeighboursAt(int row, int col) {
 		Set&lt;Cell&gt; result = new HashSet&lt;Cell&gt;();
-		for (int rowIndex = row - 1; rowIndex &lt;= row + 1; rowIndex++) {
-			if (rowIndex &gt;= 0 &amp;&amp; rowIndex &lt; field.length) {
-				String[] currentRow = field[rowIndex];
-				for (int colIndex = col - 1; colIndex &lt;= col + 1; colIndex++) {
-					if (colIndex &gt;= 0 &amp;&amp; colIndex &lt; currentRow.length) {
-						if (!(rowIndex == row &amp;&amp; colIndex == col)) {
-							result.add(new Cell(rowIndex, colIndex));
-						}
-					}
-				}
+		for (int rowIndex = Math.max(0, row - 1); rowIndex &lt;= Math.min(row + 1,
+				getHeight() - 1); rowIndex++) {
+			result.addAll(getRowNeighbours(row, col, rowIndex));
+		}
+		return result;
+	}
+
+	private Set&lt;Cell&gt; getRowNeighbours(int row, int col, int rowIndex) {
+		Set&lt;Cell&gt; result = new HashSet&lt;Cell&gt;();
+		for (int colIndex = Math.max(col - 1, 0); colIndex &lt;= Math.min(col + 1,
+				getWidth() - 1); colIndex++) {
+			if (!(rowIndex == row &amp;&amp; colIndex == col)) {
+				result.add(cellAt(rowIndex, colIndex));
 			}
 		}
 		return result;
 	}
-	
+
+	private int getWidth() {
+		return grid[0].length;
+	}
+
+	private int getHeight() {
+		return grid.length;
+	}
+
 	@Override
 	public String toString() {
 		String result = &quot;&quot;;
-		for (String[] row : field) {
+		for (Cell[] row : grid) {
 			result += &quot;[&quot;;
-			for (String cell : row) {
+			for (Cell cell : row) {
 				result += cell + &quot; &quot;;
 			}
 			result = result.substring(0, result.length() - 1);
@@ -56,4 +67,14 @@ public class Field {
 		}
 		return result;
 	}
+
+	public int getNumberOfAdjacentBombsAt(int row, int col) {
+		int result = 0;
+		for (Cell cell : getNeighboursAt(row, col)) {
+			if (cell.isBomb()) {
+				result++;
+			}
+		}
+		return result;
+	}
 }</diff>
      <filename>minesweeper_java/src/main/java/org/minesweeper/Field.java</filename>
    </modified>
    <modified>
      <diff>@@ -12,20 +12,20 @@ public class FieldTest {
 	@Test
 	public void shouldStartEmpty() {
 		Field unit = new Field(2, 2);
-		assertEquals(&quot;.&quot;, unit.cellAt(0, 0));
-		assertEquals(&quot;.&quot;, unit.cellAt(0, 1));
-		assertEquals(&quot;.&quot;, unit.cellAt(1, 0));
-		assertEquals(&quot;.&quot;, unit.cellAt(1, 1));
+		assertEquals(new Cell(0, 0, false), unit.cellAt(0, 0));
+		assertEquals(new Cell(0, 1, false), unit.cellAt(0, 1));
+		assertEquals(new Cell(1, 0, false), unit.cellAt(1, 0));
+		assertEquals(new Cell(1, 1, false), unit.cellAt(1, 1));
 	}
 
 	@Test
 	public void shouldAllowPlacingBombs() {
 		Field unit = new Field(2, 2);
 		unit.placeBombAt(0, 1);
-		assertEquals(&quot;.&quot;, unit.cellAt(0, 0));
-		assertEquals(&quot;*&quot;, unit.cellAt(0, 1));
-		assertEquals(&quot;.&quot;, unit.cellAt(1, 0));
-		assertEquals(&quot;.&quot;, unit.cellAt(1, 1));
+		assertEquals(new Cell(0, 0, false), unit.cellAt(0, 0));
+		assertEquals(new Cell(0, 1, true), unit.cellAt(0, 1));
+		assertEquals(new Cell(1, 0, false), unit.cellAt(1, 0));
+		assertEquals(new Cell(1, 1, false), unit.cellAt(1, 1));
 	}
 
 	@Test
@@ -34,42 +34,97 @@ public class FieldTest {
 		unit.placeBombAt(0, 0);
 		unit.placeBombAt(1, 0);
 		unit.placeBombAt(2, 2);
-		assertEquals(&quot;[* . .]&quot;+
-				     &quot;[* . .]&quot;+
-				     &quot;[. . *]&quot;, unit.toString());
+		assertEquals(&quot;[* . .]&quot; + &quot;[* . .]&quot; + &quot;[. . *]&quot;, unit.toString());
 	}
-	
-	
+
 	@Test
 	public void shouldFindNeighbours() {
 		Field unit = new Field(3, 3);
 		Set&lt;Cell&gt; cells = unit.getNeighboursAt(1, 1);
 		Set&lt;Cell&gt; expected = new HashSet&lt;Cell&gt;();
-		expected.add(new Cell(0, 0));
-		expected.add(new Cell(0, 1));
-		expected.add(new Cell(0, 2));
-		expected.add(new Cell(1, 0));
-		expected.add(new Cell(1, 2));
-		expected.add(new Cell(2, 0));
-		expected.add(new Cell(2, 1));
-		expected.add(new Cell(2, 2));
+		expected.add(new Cell(0, 0, false));
+		expected.add(new Cell(0, 1, false));
+		expected.add(new Cell(0, 2, false));
+		expected.add(new Cell(1, 0, false));
+		expected.add(new Cell(1, 2, false));
+		expected.add(new Cell(2, 0, false));
+		expected.add(new Cell(2, 1, false));
+		expected.add(new Cell(2, 2, false));
 		assertEquals(expected.size(), cells.size());
 		for (Cell expectedCell : expected) {
 			assertTrue(cells.contains(expectedCell));
 		}
 	}
-	
+
 	@Test
 	public void shouldFindNeighboursAtCorner() {
 		Field unit = new Field(3, 3);
 		Set&lt;Cell&gt; cells = unit.getNeighboursAt(0, 0);
 		Set&lt;Cell&gt; expected = new HashSet&lt;Cell&gt;();
-		expected.add(new Cell(0, 1));
-		expected.add(new Cell(1, 0));
-		expected.add(new Cell(1, 1));
+		expected.add(new Cell(0, 1, false));
+		expected.add(new Cell(1, 0, false));
+		expected.add(new Cell(1, 1, false));
 		assertEquals(expected.size(), cells.size());
 		for (Cell expectedCell : expected) {
 			assertTrue(cells.contains(expectedCell));
 		}
 	}
+
+	@Test
+	public void shouldFindNeighboursAtBottomCorner() {
+		Field unit = new Field(3, 3);
+		Set&lt;Cell&gt; cells = unit.getNeighboursAt(2, 2);
+		Set&lt;Cell&gt; expected = new HashSet&lt;Cell&gt;();
+		expected.add(new Cell(1, 2, false));
+		expected.add(new Cell(1, 1, false));
+		expected.add(new Cell(2, 1, false));
+		assertEquals(expected.size(), cells.size());
+		for (Cell expectedCell : expected) {
+			assertTrue(cells.contains(expectedCell));
+		}
+	}
+
+	@Test
+	public void shouldGetZeroAdjacentBombs() {
+		Field unit = new Field(3, 3);
+		int bombs = unit.getNumberOfAdjacentBombsAt(2, 2);
+		assertEquals(0, bombs);
+	}
+
+	@Test
+	public void shouldGetNumberOfAdjacentBombs() {
+		Field unit = new Field(3, 3);
+		unit.placeBombAt(1, 1);
+		int bombs = unit.getNumberOfAdjacentBombsAt(2, 2);
+		assertEquals(1, bombs);
+	}
+
+	@Test
+	public void shouldGetNumberOfAdjacentBombsOnARectangle() {
+		Field unit = new Field(6, 3);
+		unit.placeBombAt(5, 0);
+		int bombs = unit.getNumberOfAdjacentBombsAt(5, 1);
+		assertEquals(1, bombs);
+	}
+
+	@Test
+	public void shouldGetMultipleAdjacentBombsOnARectangle() {
+		Field unit = new Field(6, 3);
+		unit.placeBombAt(5, 0);
+		unit.placeBombAt(5, 1);
+		unit.placeBombAt(5, 2);
+		int bombs = unit.getNumberOfAdjacentBombsAt(4, 1);
+		assertEquals(3, bombs);
+	}
+
+	@Test
+	public void shouldIgnoreNonAdjacentBombsOnARectangle() {
+		Field unit = new Field(6, 7);
+		unit.placeBombAt(5, 0);
+		unit.placeBombAt(3, 3);
+		unit.placeBombAt(5, 2);
+		int bombs = unit.getNumberOfAdjacentBombsAt(4, 1);
+		assertEquals(2, bombs);
+	}
+
 }</diff>
      <filename>minesweeper_java/src/test/java/org/minesweeper/FieldTest.java</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>2d498c4bee286fbcfb5505e02c2d84a45cb52fd8</id>
    </parent>
  </parents>
  <author>
    <name>Ivan Sanchez</name>
    <email>ivansanchez@sanchez.config</email>
  </author>
  <url>http://github.com/codingdojolondon/sessions/commit/425137efa511540f30bac88ecda792803ace080c</url>
  <id>425137efa511540f30bac88ecda792803ace080c</id>
  <committed-date>2009-03-26T11:54:45-07:00</committed-date>
  <authored-date>2009-03-26T11:54:45-07:00</authored-date>
  <message>Minesweeper implementation generated at the Software Craftsmanship Conference 2009 (http://parlezuml.com/softwarecraftsmanship/sessions/5_reasons_to_have_a_coding_dojo.htm)</message>
  <tree>766170a937b16348ccc13e143f925685caa3db27</tree>
  <committer>
    <name>Ivan Sanchez</name>
    <email>ivansanchez@sanchez.config</email>
  </committer>
</commit>
