public virtual bool IsInterceptedWith(AbstractFigure other) { if (_definingPoints.Intersect(other._definingPoints).Count() != 0) { return(true); } foreach (var point in _definingPoints) { if (other.IsFillerPoint(point)) { return(true); } } // 2-th cicle nesesarry because _definingPoints don't contains all points of a figure foreach (var point in other._definingPoints) { if (IsFillerPoint(point)) { return(true); } } return(false); }
public override bool Equals(object obj) { if (obj == null) { return(false); } AbstractFigure other = obj as AbstractFigure; if (other == null) { return(false); } if (GetType() != other.GetType()) { return(false); } if (_definingPoints.Count != other._definingPoints.Count) { return(false); } int length = _definingPoints.Count; bool result = false; for (int i = 0; i < length; i++) { if (_definingPoints[i] == other._definingPoints[0]) // For the lack of reference to the position in the _definingPoints list { result = true; for (int j = 0, k = i; j < length; j++, k++) { if (k >= length) { k = 0; } if (_definingPoints[k] != other._definingPoints[j]) { return(false); } } } } return(result); }