Bu işinize yarar sanırım
public class Rectangle {
int width;
int height;
int getArea() {
return width * height;
}
int getPerimeter() {
return 2 * (width + height);
}
public int getHeight() {
return height;
}
public void setHeight(int _height) throws Exception {
if (_height < 0 || _height > 20) {
throw new Exception();
}
height = _height;
}
public int getWidth() {
return width;
}
public void setWidth(int _width) throws Exception {
if (_width < 0 || _width > 20) {
throw new Exception();
}
width = _width;
}
}
The Man Who Loved Algorithm&Ubuntu.
www.burakamasyali.com
|