update,
This commit is contained in:
40
_resources/it114105/itp4510/Lab01/Lab1.2/q3/Rectangle.java
Normal file
40
_resources/it114105/itp4510/Lab01/Lab1.2/q3/Rectangle.java
Normal file
@@ -0,0 +1,40 @@
|
||||
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user