- All Known Implementing Classes:
Circle,ConvexPolygon,Rectangle,Triangle
@NullMarked
public interface Shape
Shape is a common interface for geometric shapes.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Vector2DcalculateCentroid(Vector2D[] points) Calculates and returns the centroid of the shape represented by the array of points.booleanChecks if this Shape contains a point.floatgetArea()Calculates the area of this shape and return it.default Vector2DCalculates and returns the centroid of thisShape.Vector2D[]points()
-
Method Details
-
contains
Checks if this Shape contains a point.- Parameters:
point- the point to check- Returns:
- true if this shape contains the point
-
points
Vector2D[] points()- Returns:
- the array of points making up this shape
-
getArea
float getArea()Calculates the area of this shape and return it.- Returns:
- the area of this shape
-
getCentroid
Calculates and returns the centroid of thisShape.- Returns:
- the centroid
-
calculateCentroid
Calculates and returns the centroid of the shape represented by the array of points.- Parameters:
points- the points of the shape- Returns:
- the centroid
-