Files
004_comission/_resources/it114105/itp4510/Lab01/Lab1.2/q3/Rectangle.java
louiscklaw 6c60a73f30 update,
2025-01-31 19:15:17 +08:00

41 lines
860 B
Java

public class Rectangle extends Shape{
private Point topLeft;
private double width;
private double height;
public Rectangle(double width, double height, double x, double y) {
super("rectangle");
topLeft = new Point(x, y);
this.width = width;
this.height = height;
}
public double getWidth() {
return width;
}
public double getHeight() {
return height;
}
public Point getTopLeft() {
return topLeft;
}
public void setWidth(double width) {
this.width = width;
}
public void setHeight(double height) {
this.height = height;
}
public double getArea() {
return width * height;
}
public String toString() {
return "top left=" + topLeft.toString() + "; width=" + width + "; height=" + height;
}
}