类 JsonExportVisitor

java.lang.Object
com.example.graphics.visitor.JsonExportVisitor
所有已实现的接口:
ShapeVisitor

public class JsonExportVisitor extends Object implements ShapeVisitor
Visitor implementation that exports shapes to JSON format. This is an implementation of the Visitor pattern.
  • 字段详细资料

    • shapes

      private org.json.JSONArray shapes
  • 构造器详细资料

    • JsonExportVisitor

      public JsonExportVisitor()
      Constructor initializes the JSON array
  • 方法详细资料

    • visit

      public void visit(Circle circle)
      从接口复制的说明: ShapeVisitor
      Visit a Circle shape
      指定者:
      visit 在接口中 ShapeVisitor
      参数:
      circle - the circle to visit
    • visit

      public void visit(Rectangle rectangle)
      从接口复制的说明: ShapeVisitor
      Visit a Rectangle shape
      指定者:
      visit 在接口中 ShapeVisitor
      参数:
      rectangle - the rectangle to visit
    • visit

      public void visit(Line line)
      从接口复制的说明: ShapeVisitor
      Visit a Line shape
      指定者:
      visit 在接口中 ShapeVisitor
      参数:
      line - the line to visit
    • visit

      public void visit(Triangle triangle)
      从接口复制的说明: ShapeVisitor
      Visit a Triangle shape
      指定者:
      visit 在接口中 ShapeVisitor
      参数:
      triangle - the triangle to visit
    • getJsonOutput

      public String getJsonOutput()
      Get the JSON representation of all visited shapes
      返回:
      a JSON string representing all shapes
    • clear

      public void clear()
      Clear all shapes from the visitor