public class Rect2D implements Shape {
int width, height;
public Rect2D(int width, int height) {
setWidth(width);
setHeight(height);
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
// Interface'deki iki method dolduruluyor.
public double getArea() {
return width * height;
}
public double getEnv() {
return 2 * (width + height);
}
}
Dosyayı İndir