定义一个表示坐标点的类Point

时间:2013.10.23 发布人:cll931006

定义一个表示坐标点的类Point

已解决问题

谷歌cll931006用户在2013.10.23提交了关于“婪定义一个表示坐标点的类Point”的提问,欢迎大家涌跃发表自己的观点。目前共有2个回答,最后更新于2024-12-04T06:46:27。


成员变量有横坐标x和纵坐标y,方法show显示点坐标,构造方法为参数x\y赋值;编写J**a程序,在main方法中构造两个对象,再创建方法getMiddle取两点所构成险段的中点坐标。

packagecom.minirisoft;


importj**ax.swing.JOptionPane;


publicclassPoint{

staticvoidShow(Doublea,Doubleb)

{

Stringstr;

str=JOptionPane.showInputDialog("请输入纵坐标数:");

a=Double.parseDouble(str);

str=JOptionPane.showInputDialog("请输入横坐标数:");

b=Double.parseDouble(str);

System.out.print("("+a);

System.out.println(","+b+")");

}

@SuppressWarnings("**ll")

staticvoidgetMiddle()

{

Doublea=**ll,b=**ll,x=**ll,y=**ll;

Show(a,b);

Show(x,y);

a=(a+x)/2;

b=(b+y)/2;

System.out.print("("+a);

System.out.println(","+b+")");


}

publicstaticvoidmain(Stringargs[])

{

getMiddle();

}

}


希望大家能够帮助她。

详细问题描述及疑问:


成员变量有横坐标x和纵坐标y,方法show显示点坐标,构造方法为参数x\y赋值;编写J**a程序,在main方法中构造两个对象,再创建方法getMiddle取两点所构成险段的中点坐标。

packagecom.minirisoft;


importj**ax.swing.JOptionPane;


publicclassPoint{

staticvoidShow(Doublea,Doubleb)

{

Stringstr;

str=JOptionPane.showInputDialog("请输入纵坐标数:");

a=Double.parseDouble(str);

str=JOptionPane.showInputDialog("请输入横坐标数:");

b=Double.parseDouble(str);

System.out.print("("+a);

System.out.println(","+b+")");

}

@SuppressWarnings("**ll")

staticvoidgetMiddle()

{

Doublea=**ll,b=**ll,x=**ll,y=**ll;

Show(a,b);

Show(x,y);

a=(a+x)/2;

b=(b+y)/2;

System.out.print("("+a);

System.out.println(","+b+")");


}

publicstaticvoidmain(Stringargs[])

{

getMiddle();

}

}


期待您的答案,我不知道说什么才好,除了谢谢 !
希望以下的回答,能够帮助你。

第1个回答

用户名:樱雪灬梦  

什么意思,说清楚些。。。。

第2个回答

用户名:SNK_Shit  

两点的中点吗?拿一个坐标的X与另外一个坐标的X相减,取绝对值,Y也一样