Dr.Javaを使って正方形のクラスを作ろうとしています。長方形クラスからほとんどのコードを取得しましたが、混乱してしまいました。私は現在、Javaに関しては初心者なので、今本当に迷っています。私の平方クラスを修正する方法に関する修正またはヒントがあれば、私に知らせてください. ありがとう
package graphics2;
/**
* A class that represents a square with given origin, width, and height.
*/
public class Square extends Graphics {
// The private width and height of this square.
private double width = 0;
private double height = 0;
/**
* Constructs a square with given origin, width, and height.
*/
public Square(Point origin, double side) {
super(origin, side, side);
setOrigin(new Point(0, 0));
width = height = side;
}
/**
* Constructs a square with given width and height at origin (0, 0).
*/
public Square(double side) {
setOrigin(new Point(0, 0));
width = height = side;
}
/**
* Returns the square's side of this square.
*/
public double getSide() {return width;}
/**
* Returns the width coordinate of this square.
*/
public double getWidth() {return width; }
/**
* Returns the height coordinate of this square.
*/
public double getHeight() {return height; }
/**
* Returns the area of this square.
*/
public double area() {
return width * height;
}
}
また、私が受け取っているエラーは次のとおりです。
1 error found:
File: C:\Users\GreatOne\Desktop\06Labs-\graphics2\Square.java [line: 15]
Error: The constructor graphics2.Graphics(graphics2.Point, double, double) is undefined