
Could anybody help me on this problem, Write two Rectangle objects with the following properties:
Rectangle1: Height 15 width 53 Y 25 X 15
Rectangle2: height 47 Width 60 Y 12 X 0
It's to be used four-argument constructor, toString(), getWidth(), getHeight(), Println()

Hi Friend,
Try the following code:
class Rectangle{
private int width;
private int height;
int x;
int y;
Rectangle(int newx, int newy, int newwidth, int newheight) {
this.x=newx;
this.y=newy;
this.width=newwidth;
this.height=newheight;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
void Println() {
System.out.println(toString());
}
public String toString(){
return "Rectangle(" + getX() + ", " + getY() +"), width " + getWidth() + ", height " + getHeight();
}
public static void main(String[]args){
Rectangle Rectangle1=new Rectangle(15,25,53,15);
Rectangle1.Println();
Rectangle Rectangle2=new Rectangle(0,12,60,47);
Rectangle2.Println();
}
}
Thanks