package com.godoro.geometry;
import java.io.Serializable;
public class Rectangle implements Serializable{
private double width;
private double height;
public Rectangle(double width, double height) {
this.width = width;
this.height = height;
}
public Rectangle() {
}
public double getWidth(){
return width;
}
public void setWidth(double width){
if(width<0){
this.width=-width;
}else{
this.width=width;
}
// if(width<0){
// throw new IllegalArgumentException("Genişlik eksi olamaz "+width);
// }
this.width=width;
}
public double getHeight() {
return height;
}
public void setHeight(double height) {
this.height = height;
}
public double getArea(){
return width*height;
}
public double getPerimeter(){
return 2*(width+height);
}
}
Dosyayı İndir