类 Rectangle

java.lang.Object
com.example.graphics.model.Rectangle
所有已实现的接口:
Shape

public class Rectangle extends Object implements Shape
Rectangle implementation of the Shape interface.
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    private int
     
    private int
     
    private int
     
    private int
     
  • 构造器概要

    构造器
    构造器
    说明
    Rectangle(int x, int y, int width, int height)
    Constructs a rectangle with the specified parameters
  • 方法概要

    修饰符和类型
    方法
    说明
    void
    Accept method for the Visitor pattern
    Clone the shape
    int
    Get the height of the rectangle
    int
    Get the width of the rectangle
    int
    Get the x coordinate of the shape
    int
    Get the y coordinate of the shape
    void
    setHeight(int height)
    Set the height of the rectangle
    void
    setPosition(int x, int y)
    Set the position of the shape
    void
    setSize(int width, int height)
    Set both width and height of the rectangle at once
    void
    setWidth(int width)
    Set the width of the rectangle

    从类继承的方法 java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 字段详细资料

    • x

      private int x
    • y

      private int y
    • width

      private int width
    • height

      private int height
  • 构造器详细资料

    • Rectangle

      public Rectangle(int x, int y, int width, int height)
      Constructs a rectangle with the specified parameters
      参数:
      x - the x coordinate of the top-left corner
      y - the y coordinate of the top-left corner
      width - the width of the rectangle
      height - the height of the rectangle
  • 方法详细资料

    • getX

      public int getX()
      从接口复制的说明: Shape
      Get the x coordinate of the shape
      指定者:
      getX 在接口中 Shape
      返回:
      x coordinate
    • getY

      public int getY()
      从接口复制的说明: Shape
      Get the y coordinate of the shape
      指定者:
      getY 在接口中 Shape
      返回:
      y coordinate
    • setPosition

      public void setPosition(int x, int y)
      从接口复制的说明: Shape
      Set the position of the shape
      指定者:
      setPosition 在接口中 Shape
      参数:
      x - the x coordinate
      y - the y coordinate
    • getWidth

      public int getWidth()
      Get the width of the rectangle
      返回:
      the width
    • setWidth

      public void setWidth(int width)
      Set the width of the rectangle
      参数:
      width - the new width
    • getHeight

      public int getHeight()
      Get the height of the rectangle
      返回:
      the height
    • setHeight

      public void setHeight(int height)
      Set the height of the rectangle
      参数:
      height - the new height
    • setSize

      public void setSize(int width, int height)
      Set both width and height of the rectangle at once
      参数:
      width - the new width
      height - the new height
    • accept

      public void accept(ShapeVisitor visitor)
      从接口复制的说明: Shape
      Accept method for the Visitor pattern
      指定者:
      accept 在接口中 Shape
      参数:
      visitor - the visitor to accept
    • clone

      public Shape clone()
      从接口复制的说明: Shape
      Clone the shape
      指定者:
      clone 在接口中 Shape
      覆盖:
      clone 在类中 Object
      返回:
      a clone of this shape