Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Rectangle {
- int x, y, width, height;
- public Rectangle(int x, int y, int width, int height) throws IllegalArgumentException {
- if (width < 0 || height < 0) throw new IllegalArgumentException();
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
- }
- public int getHeight() {
- return height;
- }
- public int getWidth() {
- return width;
- }
- public int getX() {
- return x;
- }
- public int getY() {
- return y;
- }
- public String toString() {
- return String.format("Rectangle[x=%d,y=%d,width=%d,height=%d]", x, y, width, height);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement