Esempio n. 1
0
        public void TestIntersection(int circleX1, int circleY1, int circleRadio1, int circleX2, int circleY2, int circleRadio2, bool expected)
        {
            Circle circle1 = new Circle()
            {
                X = circleX1, Y = circleY1, Radio = circleRadio1
            };
            Circle circle2 = new Circle()
            {
                X = circleX2, Y = circleY2, Radio = circleRadio2
            };
            CalculateIntersection newIntersection = new CalculateIntersection(circle1, circle2);
            bool result = newIntersection.GetStatusIntersection();

            Assert.True(expected == result);
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(this.txtPositionX1.Text) ||
                    string.IsNullOrEmpty(this.txtPositionY1.Text) ||
                    string.IsNullOrEmpty(this.txtRadio1.Text) ||
                    string.IsNullOrEmpty(this.txtPositionX2.Text) ||
                    string.IsNullOrEmpty(this.txtPositionY2.Text) ||
                    string.IsNullOrEmpty(this.txtRadio2.Text))
                {
                    MessageBox.Show("Debe de ingresar información en los campos, recuerde solo números enteros");
                }
                else
                {
                    this.txtResult.Text = "";
                    int postionX1 = int.Parse(this.txtPositionX1.Text);
                    int postionY1 = int.Parse(this.txtPositionY1.Text);
                    int radio1    = int.Parse(this.txtRadio1.Text);

                    int postionX2 = int.Parse(this.txtPositionX2.Text);
                    int postionY2 = int.Parse(this.txtPositionY2.Text);
                    int radio2    = int.Parse(this.txtRadio2.Text);

                    Circle circle1 = new Circle()
                    {
                        X = postionX1, Y = postionY1, Radio = radio1
                    };
                    Circle circle2 = new Circle()
                    {
                        X = postionX2, Y = postionY2, Radio = radio2
                    };
                    CalculateIntersection newIntersection = new CalculateIntersection(circle1, circle2);
                    bool result = newIntersection.GetStatusIntersection();
                    this.txtResult.Text = result ? "Intersecciòn encontrada bajo los radios y centros suminstrados" : "No se encontro intersecciòn entre los centros y radios suministrados";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("se genero un error al convertir los datos, recuerde que son solo nùmeros enteros los que se van a validar");
            }
        }