You are on page 1of 2

import java.awt.geom.

Rectangle2D; public class Rectangle { public int width = 1; public int height = 1; public int y=1; public int x=1; public Rectangle(){ this(0, 0, 0,0); } public Rectangle(int width, int height, int y, int x){ this.width = width; this.height = height; this.y = y; this.x= x; } public double getWidth(){ return width; } public double getHeight(){ return height; } public double getY(){ return y; } public double getX(){ return x; } public Rectangle getBounds() { return new Rectangle (x, y, width, height); } public void translate(int x, int y) { this.x += x; this.y += y; } public static void main(String[] args){ Rectangle rectangle = new Rectangle(2, 3, 2, 3); System.out.println("Rectangle has height " + rectangle.getHeight() + " and width " +

rectangle.getWidth() + " and Y " + rectangle.getY()+" and X " + rectangle.getX()); } }

You might also like