Rectangle Shape
Create and complete the implementation of the Rectangle
class.
Your class should be public, not final and not abstract, inherit from the Shape
class,
and provide the following methods:
- Constructor that takes two
double
parameters. Creates a newRectangle
with the passed width and height. You can assume that the passed parameters are greater than zero. You should call the Shape constructor and pass it theString
"rectangle" to identify the type of this shape. - Public instance method
area
that takes no arguments and returns adouble
. Return the area of this shape:width * height
. - Override
public boolean equals(Object other)
. Returntrue
ifother
is aRectangle
with the same width and height, andfalse
otherwise. Note thatother
may benull
or not aRectangle
.
Finally, note that your class should not expose any of its internal state publicly.