Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

/ * * This class represents immutable rectangles in the plane. We say that an object is immutable if you cannot change it after it

/**
This class represents "immutable" rectangles in the plane.
We say that an object is "immutable" if you cannot change
it after it is created.
Whenever you wish to modify some aspect of a Rectangle, you
actually get a new Rectangle in which the modification has
been done.
The fields of this class are both private and final. Private
means they cannot be seen by any code outside of this class.
The final modifier means that the values of those variables
cannot be change by any code, even code in this class (except
that they can be initialized by the constructor).
*/
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
@ret

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students explore these related Databases questions