Commit 93ebb49

mo_khan <mo@mokhan.ca>
2009-05-24 06:28:50
updated the plateau to delegate to coordinate implementation of icomparable for bounds checking
1 parent 25c5796
Changed files (2)
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