Class Rectangle


  • public class Rectangle
    extends java.lang.Object
    Represents a rectangle with integer coordinates in 2D space.
    • Constructor Summary

      Constructors 
      Constructor Description
      Rectangle​(int x, int y, int width, int height)
      Constructs a rectangle with given coordinates and dimensions.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getHeight()
      Returns the height of the rectangle.
      int getWidth()
      Returns the width of the rectangle.
      int getX()
      Returns the x-coordinate of the top-left corner of the rectangle.
      int getY()
      Returns the y-coordinate of the top-left corner of the rectangle.
      void setHeight​(int height)
      Sets the height of the rectangle.
      void setWidth​(int width)
      Sets the width of the rectangle.
      void setX​(int x)
      Sets the x-coordinate of the top-left corner of the rectangle.
      void setY​(int y)
      Sets the y-coordinate of the top-left corner of the rectangle.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Rectangle

        public Rectangle​(int x,
                         int y,
                         int width,
                         int height)
        Constructs a rectangle with given coordinates and dimensions.
        Parameters:
        x - x-coordinate of the top-left corner
        y - y-coordinate of the top-left corner
        width - width
        height - height
    • Method Detail

      • getX

        public int getX()
        Returns the x-coordinate of the top-left corner of the rectangle.
        Returns:
        x-coordinate
      • setX

        public void setX​(int x)
        Sets the x-coordinate of the top-left corner of the rectangle.
        Parameters:
        x - x-coordinate
      • getY

        public int getY()
        Returns the y-coordinate of the top-left corner of the rectangle.
        Returns:
        y-coordinate
      • setY

        public void setY​(int y)
        Sets the y-coordinate of the top-left corner of the rectangle.
        Parameters:
        y - y-coordinate
      • getWidth

        public int getWidth()
        Returns the width of the rectangle.
        Returns:
        width
      • setWidth

        public void setWidth​(int width)
        Sets the width of the rectangle.
        Parameters:
        width - width
      • getHeight

        public int getHeight()
        Returns the height of the rectangle.
        Returns:
        height
      • setHeight

        public void setHeight​(int height)
        Sets the height of the rectangle.
        Parameters:
        height - height