public bool IsOnPath(MapLocation location) { foreach (var pathLocation in _path) { if (location.Equals(pathLocation)) { return(true); } } return(false); }
// Below are three different ways to code the IsOnPath method; leaving them in as notes. // 1. //LINQ IsOnPath method //public bool IsOnPath(MapLocation mapLocation) => _path.Contains(mapLocation); // 2. public bool IsOnPath(MapLocation location) { // 3. //return Array.IndexOf(pathLocations, mapLocation) >= 0; foreach (var pathLocation in _path) { if (location.Equals(pathLocation)) { return(true); } } return(false); }