Exemple #1
0
        public bool Equals(CellLocation cl)
        {
            if (cl == null)
            {
                return(false);
            }

            return(Row == cl.Row && Column == cl.Column);
        }
Exemple #2
0
        public override bool Equals(Object obj)
        {
            CellLocation cl = obj as CellLocation;

            if (cl == null)
            {
                return(false);
            }

            return(Row == cl.Row && Column == cl.Column);
        }
Exemple #3
0
        private static CellLocation TryGetNeighbourLocation(int supposedColumn, int supposedRow,
                                                            CellLocation callerLocation)
        {
            if (!AreNotNegative(supposedColumn, supposedRow) || !AreWithinRange(supposedColumn, supposedRow))
            {
                return(null);
            }

            var supposedLocation = new CellLocation(supposedColumn, supposedRow);

            return(IsDifferentFromCaller(supposedLocation, callerLocation)
                ? supposedLocation
                : null);
        }
Exemple #4
0
        public static List <CellLocation> GetNeighboursLocations(CellLocation location)
        {
            var neighbours = new List <CellLocation>();

            for (var i = -1; i < 2; i++)
            {
                for (var j = -1; j < 2; j++)
                {
                    var supposedColumn = location.Column + i;
                    var supposedRow    = location.Row + j;

                    var cl = TryGetNeighbourLocation(supposedColumn, supposedRow, location);

                    if (cl != null)
                    {
                        neighbours.Add(cl);
                    }
                }
            }

            return(neighbours);
        }
Exemple #5
0
 private static bool IsDifferentFromCaller(CellLocation x, CellLocation y)
 {
     return(!x.Equals(y));
 }