Пример #1
0
 /*
  * Validator will check to ensure:
  * 1. The length of any edge does not exceed the sum of the other two
  * 2. The points that make up the line must not reside on the same line
  */
 public void ValidateTriangle()
 {
     if ((Line1.ComputeLength() > Line2.ComputeLength() + Line3.ComputeLength()) ||
         (Line2.ComputeLength() > Line1.ComputeLength() + Line3.ComputeLength()) ||
         (Line3.ComputeLength() > Line1.ComputeLength() + Line2.ComputeLength()))
     {
         throw new ShapeException("Invalid triangle");
     }
     if (Line1.ComputeSlope() == Line2.ComputeSlope() ||
         Line2.ComputeSlope() == Line3.ComputeSlope() ||
         Line3.ComputeSlope() == Line1.ComputeSlope())
     {
         throw new ShapeException("Invalid Triangle");
     }
 }