Ejemplo n.º 1
0
        /*
         * ValidateSquare ensures that all vertecies have an angle of 90
         */
        public void ValidateSquare()
        {
            var LineAC = new Line(Line1.Point1, Line2.Point2);

            if (
                (Math.Acos((Math.Pow(Line1.ComputeLength(), 2) + Math.Pow(Line4.ComputeLength(), 2) - Math.Pow(LineAC.ComputeLength(), 2) / (2 * Line1.ComputeLength() * Line4.ComputeLength())))) != 90
                )
            {
                throw new ShapeException("Invalid rectangle");
            }
        }
Ejemplo n.º 2
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");
     }
 }
Ejemplo n.º 3
0
        public double ComputeArea()
        {
            double area = Math.Pow(Line1.ComputeLength(), 2);

            return(area);
        }
Ejemplo n.º 4
0
        public double ComputeArea()
        {
            double area = Line1.ComputeLength() * Line2.ComputeLength();

            return(area);
        }