Commit 93ebb49
Changed files (2)
product
project
product/project/Coordinate.cs
@@ -27,6 +27,11 @@ namespace mars.rover
return new Coordinate(coordinate);
}
+ public int CompareTo(Coordinate other)
+ {
+ return coordinate.CompareTo(other.coordinate);
+ }
+
public bool Equals(Coordinate other)
{
if (ReferenceEquals(null, other)) return false;
@@ -47,11 +52,6 @@ namespace mars.rover
return coordinate.GetHashCode();
}
- public int CompareTo(Coordinate other)
- {
- return coordinate.CompareTo(other.coordinate);
- }
-
public override string ToString()
{
return coordinate.ToString(CultureInfo.InvariantCulture);
product/project/Plateau.cs
@@ -2,8 +2,8 @@ namespace mars.rover
{
public class Plateau
{
- readonly uint top_x_coordinate;
- readonly uint top_y_coordinate;
+ readonly Coordinate top_x_coordinate;
+ readonly Coordinate top_y_coordinate;
public Plateau(uint top_x_coordinate, uint top_y_coordinate)
{
@@ -11,9 +11,9 @@ namespace mars.rover
this.top_y_coordinate = top_y_coordinate;
}
- public virtual bool within_boundary(uint x, uint y)
+ public virtual bool within_boundary(Coordinate x, Coordinate y)
{
- return y <= top_y_coordinate && x <= top_x_coordinate;
+ return top_y_coordinate.CompareTo(y) >= 0 && top_x_coordinate.CompareTo(x) >= 0;
}
}
}
\ No newline at end of file