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:
double
parameters.
Creates a new Rectangle
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 the String
"rectangle" to identify the type of this
shape.area
that takes no arguments and returns a double
.
Return the area of this shape: width * height
.public boolean equals(Object other)
.
Return true
if other
is a Rectangle
with the same width and height, and false
otherwise.
Note that other
may be null
or not a Rectangle
.Finally, note that your class should not expose any of its internal state publicly.
You're challenge is to write tests for this problem described above.
Stuck? You may find these lessons helpful: