Skip to content

Commit

Permalink
Is Valid Column Move
Browse files Browse the repository at this point in the history
  • Loading branch information
ajlopez committed Apr 13, 2013
1 parent f7af572 commit 97be6c3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Lawnmover/Lawnmover/Pattern.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,14 @@ public bool IsValidRowMove(int nrow, int move)

return true;
}

public bool IsValidColumnMove(int ncol, int move)
{
for (int k = 0; k < this.width; k++)
if (this.cells[k, ncol] > move)
return false;

return true;
}
}
}
17 changes: 17 additions & 0 deletions Lawnmover/LawnmoverTests/PatternTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,22 @@ public void ValidRowMove()
Assert.IsFalse(pattern.IsValidRowMove(1, 2));
Assert.IsFalse(pattern.IsValidRowMove(1, 1));
}

[TestMethod]
public void ValidColumnMove()
{
Pattern pattern = new Pattern(2, 2);

pattern.SetRow(0, "1 2");
pattern.SetRow(1, "4 3");

Assert.IsTrue(pattern.IsValidColumnMove(0, 4));
Assert.IsFalse(pattern.IsValidColumnMove(0, 1));
Assert.IsFalse(pattern.IsValidColumnMove(0, 0));

Assert.IsTrue(pattern.IsValidColumnMove(1, 3));
Assert.IsFalse(pattern.IsValidColumnMove(1, 2));
Assert.IsFalse(pattern.IsValidColumnMove(1, 1));
}
}
}

0 comments on commit 97be6c3

Please sign in to comment.