2.编写一个名为Point的类以描述平面上的一个点,它包含点的X坐标和Y的坐标这两个数据段。要求提供对其中任何一个数据字段进行设置与获取的方法,以及求两点之间的距离方法,还要求有一个tostring()的方法,以返回表示点的(x,y)坐标的字符串。
Point类
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication3
{
    class Point
    {
        private double  _x;
        private double _y;
        private double  a;
        private double  b;
        public double  X
        {
            get
            {
                return _x;
            }
            set
            {
                _x = value;
            }
        }
        public double Y
        {
            get
            {
                return _y;
            }
            set
            {
                _y = value;
            }
        }
        public double A
        {
            get
            {
                return A;
            }
            set
            {
                a = value;
            }
        }
        public double B
        {
            get
            {
                return b;
            }
            set
            {
                b = value;
            }
        }
        public double  distant()
        {
            double  x, y,z;
            x = Math.Pow((_x - a), 2);
            y = Math.Pow((_y - b), 2);
            z = Math.Sqrt(x+y);
            Console.Write(z);
            return z;
        }
        public void toString()
        {
            Console.Write("("+_x+","+_y+")");
           
        }
 

    }
}
 
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {

            Point p = new Point();
            p.X = 4;
            p.Y = 4;
            p.A = 5;
            p.B = 5;
            p.distant();
            p.toString();
        }
    }
}