using System;class Point{\x05public int x,y;\x05public Point() \x05{\x05\x05x = 0;\x05\x05y = 0;\x05}\x05public Point(int x,int y)\x05{\x05\x05this.x=x;this.y=y;//\x05}\x05public override string ToString()\x05{\x05\x05return(String.Format("({0},{1})"
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 07:09:05
using System;class Point{\x05public int x,y;\x05public Point() \x05{\x05\x05x = 0;\x05\x05y = 0;\x05}\x05public Point(int x,int y)\x05{\x05\x05this.x=x;this.y=y;//\x05}\x05public override string ToString()\x05{\x05\x05return(String.Format("({0},{1})"
using System;
class Point
{
\x05public int x,y;
\x05public Point()
\x05{
\x05\x05x = 0;
\x05\x05y = 0;
\x05}
\x05public Point(int x,int y)
\x05{
\x05\x05this.x=x;this.y=y;//
\x05}
\x05public override string ToString()
\x05{
\x05\x05return(String.Format("({0},{1})",x,y));
\x05}
}
class MainClass
{
\x05static void Main()
\x05{
\x05\x05Point p1 = new Point();
\x05\x05Point p2 = new Point(5,3);
\x05\x05Console.WriteLine("Point 1的坐标为{0}",p1);
\x05\x05Console.WriteLine("Point 2的坐标为{0}",p2);
\x05}
}
using System;class Point{\x05public int x,y;\x05public Point() \x05{\x05\x05x = 0;\x05\x05y = 0;\x05}\x05public Point(int x,int y)\x05{\x05\x05this.x=x;this.y=y;//\x05}\x05public override string ToString()\x05{\x05\x05return(String.Format("({0},{1})"
using System;
class Point//创建一个Point类
{
public int x, y;//声明xy两个工友字段
public Point() //无参数构造函数
{
x = 0;//在无参数构造函数中赋值xy
y = 0;
}
public Point(int x, int y)//带参数构造函数
{
this.x=x;this.y=y;//<!--把函数内容补充完整-->
}
public override string ToString()//重写Tostring方法
{
return(String.Format("({0},{1})", x, y));//返回xy的值顺序第一个x 第二个y 输出效果 1,1
}
}
class MainClass
{
static void Main()
{
Point p1 = new Point();//声明一个无参数的point
Point p2 = new Point(5,3);//声明一个有参数并且赋值xy的point对象
Console.WriteLine("Point 1的坐标为{0}", p1);//返回无参数的结果 结果为 0,0
Console.WriteLine("Point 2的坐标为{0}", p2);//返回有参数的point的结果 5,3
}
}
}