Question: public class Rectangle { private final double x; / / ( x , y ) is the upper left - hand corner of this rectangle

public class Rectangle
{
private final double x; //(x,y) is the upper left-hand corner of this rectangle
private final double y;
private final double width;
private final double height;
/**
@param x x-coordinate of this Rectangle's upper left-hand corner
@param y y-coordinate of this Rectangle's upper left-hand corner
@param width width of this Rectangle, must be strictly positive
@param height height of this Rectangle, must be strictly positive
@throws IllegalArgumentException when width is not strictly positive
@throws IllegalArgumentException when height is not strictly positive
*/
public Rectangle(double x, double y, double width, double height)
{
// implementation
}
/**
@return the x-coordinate of this Rectangle's upper left-hand corner
*/
public double getX()
{
// implementation
}
/**
@return the y-coordinate of this Rectangle's upper left-hand corner
*/
public double getY()
{
// implementation
}
/**
@return the value of this Rectangle's width
*/
public double getWidth()
{
// implementation
}
/**
@return the value of this Rectangle's height
*/
public double getHeight()
{
// implementation
}
/**
@return the value of this Rectangle's area
*/
public double getArea()
{
// implementation
}
/**
@return the value of this Rectangle's perimeter
*/
public double getPerimeter()
{
// implementation
}
/**
Return a Rectangle object that has the same upper left-hand
corner and height as this Rectangle but with the given width.
@param width the width for the new rectangle
@return a Rectangle with the given width and the same upper left-hand corner and height as this rectangle
*/
public Rectangle setWidth(double width)
{
// implementation
}
/**
Return a Rectangle object that has the same upper left-hand
corner and width as this Rectangle but with the given height.
@param height the height for the new rectangle
@return a Rectangle with the given height and the same upper left-hand corner and width as this rectangle
*/
public Rectangle setHeight(double height)
{
// implementation
}
/**
Return a Rectangle object that has the same width and height
as this Rectangle but the new Rectangle should have its upper
left-hand corner at the given x and y values.
@param x x-coordinate for the new Rectangle's upper left-hand corner
@param y y-coordinate for the new Rectangle's upper left-hand corner
@return a Rectangle with the same dimensions but a different upper left-hand corner
*/
public Rectangle moveTo(double x, double y)
{
// implementation
}
/**
Return a Rectangle object that has the same width and height
as this Rectangle but the new Rectangle should have its upper
left-hand corner translated from where this Rectangle's upper
left-hand corner is.
@param dx amount by which to change the x-coordinate from this Rectangle
@param dy amount by which to change the y-coordinate from this Rectangle
@return a Rectangle with the same dimensions but a different upper left-hand corner
*/
public Rectangle translateBy(double dx, double dy)
{
// implementation
}
/**
Return a Rectangle object that has the same upper left-hand
corner as this Rectangle, but the new Rectangle should have
the width and height from this Rectangle flipped.
@return a Rectangle with the same upper left-hand corner but with the dimensions flipped
*/
public Rectangle flip()
{
// implementation
}
/**
Return a Rectangle object with the same upper left-hand
corner as this Rectangle, a width that is the maximum
of the widths from the two input Rectangles, and with
a height that is the maximum of the heights from the
two input Rectangles.
@param r1 the first input Rectangle
@param r2 the second input Rectangle
@return a Rectangle with the same upper left-hand corner as this one, and maximal dimensions
*/
public Rectangle maximal(Rectangle r1, Rectangle r2)
{
// implementation
}
public String toString()
{
return "Rectangle[x="+x+", y="+y+", width="+width+", height="+height+"]";
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!