【水汐のC#窗体】 1. 设计一个简单的Windows应用程序,在文本框中输入两个点的坐标值,单击“确定”时显示两点之间的距离。 要求定义一个Point类,包括

  1. 设计一个简单的Windows应用程序,在文本框中输入两个点的坐标值,单击“确定”时显示两点之间的距离。
    要求定义一个Point类,包括
  1. 两个私有字段表示两个坐标值
  2. 一个构造函数通过传入的参数对坐标值初始化。
  3. 两个只读属性对坐标值的读取。
  4. 一个方法包含一个Point类对象作为形参计算该对象和自己的距离。
		class point
		{
			private int x;
			private int y;
			public point(int a,int b) {
				x = a;
				y = b;
			}
					public int X
			{
				get
				{
					return x;
				}
			}
			public int Y
			{
				get
				{
					return y;
				}
			}
			public double longs(point a)
			{
				double dd;
				dd = (a.x - this.x) * (a.x - this.x) + (a.y - this.y) * (a.y - this.y);
				dd = Math.Sqrt(dd);
				return dd;
			}
		}
		private void button6_Click(object sender, EventArgs e)
		{
			this.Close();
		}
		private void button5_Click(object sender, EventArgs e)
		{
			int  x1 =Convert.ToInt32(textBox1.Text);
			int  y1 = Convert.ToInt32(textBox4.Text);
			int x2 = Convert.ToInt32(textBox2.Text);
			int y2 = Convert.ToInt32(textBox5.Text);
			point a1=new point(x1,y1);
			point a2 = new point(x2, y2);
			textBox3.Text = Convert.ToString(a1.longs(a2));
		}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值