问题是这样的:// 为什么super(x,y), 父类Point中x,y必须是静态的?
我也没弄懂,
于是发上来请各位大哥帮帮解释一下:
public class Point {
protected static int x;
protected static int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
public String getPosition() {
return ("(" + this.x + "," + this.y + ")");
}
public void draw() {
System.out.println("在坐标:x:" + x + ",y:" + y + "处画一个点");
}
}
class Trigle extends Point {
public Point a;
public Point b;
public Point c;
public Trigle(int x1, int y1, int x2, int y2, int x3, int y3) {
super(x, y); // 为什么super(x,y), 父类Point中x,y必须是静态的?
Trigle(x1, y1, x2, y2, x3, y3);
}
public void Trigle(int x1, int y1, int x2, int y2, int x3, int y3) {
this.a = new Point(x1, y1);
this.b = new Point(x2, y2);
this.c = new Point(x3, y3);
}
public void drawTrigle(int x1, int y1, int x2, int y2, int x3, int y3) {
System.out.println("三角形三个顶点为:a:" + a.getPosition() + ",b:"
+ b.getPosition() + ",c:" + c.getPosition());
}
}