Interface Shape

All Known Implementing Classes:
Circle, Rectangle, Triangle

@NullMarked public interface Shape
Shape is a common interface for geometric shapes.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Vector2D
    Calculates and returns the centroid of the shape represented by the array of points.
    boolean
    Checks if this Shape contains a point.
    float
    Calculates the area of this shape and return it.
    default Vector2D
    Calculates and returns the centroid of this Shape.
     
  • Method Details

    • contains

      boolean contains(Vector2D point)
      Checks if this Shape contains a point.
      Parameters:
      point - the point to check
      Returns:
      true if this shape contains the point
    • getPoints

      Vector2D[] getPoints()
      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

      default Vector2D getCentroid()
      Calculates and returns the centroid of this Shape.
      Returns:
      the centroid
    • calculateCentroid

      static Vector2D calculateCentroid(Vector2D[] points)
      Calculates and returns the centroid of the shape represented by the array of points.
      Parameters:
      points - the points of the shape
      Returns:
      the centroid