public void Visit(Trapeze figure) { var a = Math.Sqrt(Math.Pow(figure.A.X - figure.B.X, 2) + Math.Pow(figure.A.Y - figure.B.Y, 2)); var b = Math.Sqrt(Math.Pow(figure.C.X - figure.B.X, 2) + Math.Pow(figure.C.Y - figure.B.Y, 2)); var c = Math.Sqrt(Math.Pow(figure.D.X - figure.C.X, 2) + Math.Pow(figure.D.Y - figure.C.Y, 2)); var d = Math.Sqrt(Math.Pow(figure.D.X - figure.A.X, 2) + Math.Pow(figure.D.Y - figure.A.Y, 2)); Console.WriteLine(string.Format("Периметр = {0}", a + b + c + d)); }
public void Visit(Trapeze figure) { var a = Math.Sqrt(Math.Pow(figure.A.X - figure.B.X, 2) + Math.Pow(figure.A.Y - figure.B.Y, 2)); //основание 1 var b = Math.Sqrt(Math.Pow(figure.C.X - figure.B.X, 2) + Math.Pow(figure.C.Y - figure.B.Y, 2)); var c = Math.Sqrt(Math.Pow(figure.D.X - figure.C.X, 2) + Math.Pow(figure.D.Y - figure.C.Y, 2)); //основание 2 var d = Math.Sqrt(Math.Pow(figure.D.X - figure.A.X, 2) + Math.Pow(figure.D.Y - figure.A.Y, 2)); var s = (c + a) * figure.H / 2; Console.WriteLine(string.Format("Площадь = {0}", s)); }
public void Visit(Trapeze figure) { Console.WriteLine(string.Format("Трапеция по координатам x={0} y={1}", x, y)); }