
已解决问题
谷歌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();
}
}