-1
我已經嘗試了一切,並且eclipse始終返回錯誤「方法getX()未定義類型Point」。下面是這個錯誤出現在代碼:該方法未定義爲java類型
public class Rectangle {
double Height;
double Width;//Variables for the class
double x;
double y;
public Rectangle(Point p, double width, double height) {
this.Height = height;
this.Width = width;
this.x = p.getX();
this.y = p.getY();
}
}
這個階級和階級觀點
public class Point {
double x;
double y;
public Point(double x, double y) {
this.x = x;
this.y = y;
}
public double getX() {
return this.x;
}
public double getY() {
return this.y;
}
}
每當我叫點的存取之一,我得到的錯誤,我看到的地方,你都應該每次調用訪問器時都要使用關鍵字new,但在這種情況下它不適用於我。
SIDENOTE:我對這門語言和整體編程都很陌生,所以如果你能把事情簡單化就好了,謝謝!
你確定你使用的是類'Point'而不是['java.awt.Point'(HTTP://文檔。 oracle.com/javase/7/docs/api/java/awt/Point.html)?或者其他名爲'Point'的東西?你做了一個乾淨的構建? – 2014-12-19 03:06:12
你正在輸入/使用正確的'Point'類嗎? – 2014-12-19 03:06:38
@ElliottFrisch儘管AWT Point有'getX'和'getY'。仍然可能是導入錯誤。 – Radiodef 2014-12-19 03:07:52