Esempio n. 1
0
        public void MapLocationEquality()
        {
            Location loc1 = new MapLocation (new Map (), Point.Zero);
            Location loc2 = new MapLocation (loc1);

            Assert.IsTrue (loc1.Equals (loc2));
            Assert.IsTrue (loc1 == loc2);
            Assert.IsFalse (loc1 != loc2);
        }
Esempio n. 2
0
 public bool IsOnPath(MapLocation location)
 {
     foreach (var pathLocation in _path)
     {
         if (location.Equals(pathLocation))
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 3
0
        public bool IsOnPath(MapLocation location)
        {
            foreach (var pathLocation in _path)
            {
                if (location.Equals(pathLocation)) //added a overriden Equals method in Point so we can acc check if 2 locations share the same X.Y values (same coordinates)
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 4
0
        // Determines if a location is on the path
        public bool IsOnPath(MapLocation location)
        {
            foreach (var pathLocation in _path)
            {
                // the double equal sign checks for reference equality
                // same as using ReferenceEquals(Object, Object)
                if (location.Equals(pathLocation))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 5
0
        //towers can't be on the path, so there needs to be a way to provide a
        //map location as a parameter and see if its in the path or not
        public bool IsOnPath(MapLocation location)
        {
            foreach (var pathLocation in _path)
            {
                //see Equal override in point.cs for this feature
                if (location.Equals(pathLocation))
                {
                    // diff from == where == means if its the same "obj"
                    // equal means same coordinance
                    // string, int, double == is the same as equal, meaning
                    // exact same value
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 6
0
        // Builds method.
        // Takes one parameter,
        // an object from the class MapLocation.
        // Returns true if the MapLocation is
        // on the path.
        public bool IsOnPath(MapLocation location)
        {
            // Builds for loop.
            // Iterates through of the locations
            // in the path array.
            foreach (var pathLocation in _path)
            {
                // Builds if statement.
                // Method call
                // using object name.
                if (location.Equals(pathLocation))
                {
                    return(true);
                }
            }

            // Returns false if
            // it didn't find the location in
            // the array.
            return(false);
        }
Esempio n. 7
0
        public void MapLocationInequality()
        {
            Location loc1 = new MapLocation (new Map (), new Point (1, 1));
            Location loc2 = new MapLocation (new Map (), new Point (1, 2));

            Assert.IsFalse (loc1.Equals (loc2));
            Assert.IsFalse (loc1 == loc2);
            Assert.IsTrue (loc1 != loc2);
        }