类 JsonExportVisitor
java.lang.Object
com.example.graphics.visitor.JsonExportVisitor
- 所有已实现的接口:
ShapeVisitor
Visitor implementation that exports shapes to JSON format.
This is an implementation of the Visitor pattern.
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明void
clear()
Clear all shapes from the visitorGet the JSON representation of all visited shapesvoid
Visit a Circle shapevoid
Visit a Line shapevoid
Visit a Rectangle shapevoid
Visit a Triangle shape
-
字段详细资料
-
shapes
private org.json.JSONArray shapes
-
-
构造器详细资料
-
JsonExportVisitor
public JsonExportVisitor()Constructor initializes the JSON array
-
-
方法详细资料
-
visit
从接口复制的说明:ShapeVisitor
Visit a Circle shape- 指定者:
visit
在接口中ShapeVisitor
- 参数:
circle
- the circle to visit
-
visit
从接口复制的说明:ShapeVisitor
Visit a Rectangle shape- 指定者:
visit
在接口中ShapeVisitor
- 参数:
rectangle
- the rectangle to visit
-
visit
从接口复制的说明:ShapeVisitor
Visit a Line shape- 指定者:
visit
在接口中ShapeVisitor
- 参数:
line
- the line to visit
-
visit
从接口复制的说明:ShapeVisitor
Visit a Triangle shape- 指定者:
visit
在接口中ShapeVisitor
- 参数:
triangle
- the triangle to visit
-
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
-