我是JAVA的初学者,有道题不会,哪位大哥帮个忙吧!

来源:百度知道 编辑:UC知道 时间:2024/05/15 01:12:12
定义一个描述平面坐标系统中的点及其操作的类Point.它有两个double型私有属性x和y描述点在坐标轴中的位置。该类还包含如下方法:初始化x和y的构造函数;返回x和y值的方法getX( )和getY( );将给定坐标平移w(水平)和h(垂直)的方法shiftPoint(double w,double h);判断调用该方法的点的坐标和方法中的参数点的坐标是否相等的方法pointEquals(Point p);确定点在第几象限的方法 whatQuadrant( ),并返回字符串描述;求到给定参数点的距离的方法 findDistance (Point p),返回结果保留两位小数;将点的坐标表示为字符串格式( x , y )的方法toString ( )。
编写应用程序或小程序,测试类Point,使用上面定义的各个方法并将其结果输出。“关键语句加注释”

/*
* Point.java
*
* Created on 2007��4��14��, ����8:23
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

/**
*
* @author idle~
*/
public class Point {

private double x = 0.0;
private double y = 0.0;
/** Creates a new instance of Point
* @param x
* @param y
*/
public Point(double x,double y) {
this.x = x;
this.y = y;
}

public double getX(){
return x;
}

public double getY(){
return y;
}

/**
*
* @param w
* @param h
*/
public void shiftPoint(double w,double h){
x += w;
y += h;
}

public boolean po