62,634
社区成员




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());
}
}
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);
}
看的很蛋疼的程序,貌似是一个固定点,和3个非固定点 的故事?
protected static int x;
protected static int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
//这个着实被累到了,首先是 通过this.来对类变量进行赋值……
再来,类变量时公用的……这样一弄还有三角形?都是一个点了嘛……你就算再定义1000个点,其实都是一个点诶……
继续,严重逻辑错误……继承也是让我很无语……那个super(x,y)着实让我震惊