


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



class MyRectangle2D{ private double x; private double y; private double width; private double height; public MyRectangle2D(){ x=0; y=0; width = 1; height = 1; } public MyRectangle2D(double x, double y, double w, double h){ this.x=x; this.y=y; width = w; height = h; } public double getx(){ return x; } public double gety(){ return y; } public double getw(){ return width;
public double geth(){ return height; } public void setx(double x){ this.x=x; } public void sety(double y){ this.y=y; } public void setw(double w){ width=w; } public void seth(double h){ height=h; } public double getArea(){ return (widthheight); } public double getPerimeter(){ return (2(width+height)); } public void print(){ System.out.println("Width of the rectangle = " + width);
System.out.println(r2.getArea()); System.out.println(r2.getPerimeter()); System.out.println(r2.contains(11,33)); r2.print(); System.out.println(r2.contains(r1)); System.out.println(r1.contains(r2)); } }