java,设计一个点类Point,
发布网友
发布时间:2022-04-22 06:36
我来回答
共1个回答
热心网友
时间:2023-06-10 17:18
灞曞紑鍏ㄩ儴public class Point
{
public static void main(String[] args)
{
Point p1=new Point();
Point p2=new Point(1,2);
p1.show();
p1.move(3,4);
p1.show();
p2.show();
p2.move(5,6);
p2.show();
}
Point()
{
this(0,0);
}
Point(float x,float y)
{
this.x=x;
this.y=y;
}
void move(float x,float y)
{
this.x=x;
this.y=y;
}
void show()
{
System.out.printf("(%f,%f)",x,y);
System.out.println();
}
private float x,y;
}