接口 Shape

所有已知实现类:
Circle, Line, Rectangle, Triangle

public interface Shape
Shape interface representing a graphical shape element. This is part of the Visitor pattern (accepts visitors) and will be instantiated through Factory pattern.
  • 方法概要

    修饰符和类型
    方法
    说明
    void
    Accept method for the Visitor pattern
    Clone the shape
    int
    Get the x coordinate of the shape
    int
    Get the y coordinate of the shape
    void
    setPosition(int x, int y)
    Set the position of the shape
  • 方法详细资料

    • getX

      int getX()
      Get the x coordinate of the shape
      返回:
      x coordinate
    • getY

      int getY()
      Get the y coordinate of the shape
      返回:
      y coordinate
    • setPosition

      void setPosition(int x, int y)
      Set the position of the shape
      参数:
      x - the x coordinate
      y - the y coordinate
    • accept

      void accept(ShapeVisitor visitor)
      Accept method for the Visitor pattern
      参数:
      visitor - the visitor to accept
    • clone

      Shape clone()
      Clone the shape
      返回:
      a clone of this shape