All pastes #404005 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-03-20 19:24 UTC
rendered paste body
#region inRange
    /// <summary>
    /// Tests if this point falls within range 0-Size
    /// Pre-Condition: Size is not null
    /// Post-Condition: true if both x and y of this are
    /// between 0 and their corresponding component in Size
    /// otherwise false
    /// </summary>
    /// <param name="size">upper bounds of range check</param>
    /// <returns>True if within range, otherwise false</returns>
    public bool inRange(Point size)
    {
      #region Pre-condition
      try { Check.Require(size != null); }
      catch (Exception e) { Console.Write(e.Message); }
      #endregion
      #region Code
      bool result = (X >= 0 && Y >= 0 && X < size.X && Y < size.Y);
      #endregion
      #region Post-condition
      try
      {
        if (result)
          Check.Assert(x >= 0 && x < size.X && y >= 0 && y < size.Y);
        else
          Check.Assert(x < 0 || x >= size.X || y < 0 || y >= size.Y);
      }
      catch (Exception e) { Console.Write(e.Message); }
      #endregion
      return result;
    }
    #endregion