类 ShapeFactory
java.lang.Object
com.example.graphics.factory.ShapeFactory
Factory class for creating different types of shapes.
This is an implementation of the Factory Method pattern.
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明createCircle
(int x, int y, int radius) Create a circle with the specified parameterscreateLine
(int x1, int y1, int x2, int y2) Create a line with the specified endpointscreateRectangle
(int x, int y, int width, int height) Create a rectangle with the specified parameterscreateTriangle
(int x1, int y1, int x2, int y2, int x3, int y3) Create a triangle with the specified vertices
-
构造器详细资料
-
ShapeFactory
public ShapeFactory()
-
-
方法详细资料
-
createCircle
Create a circle with the specified parameters- 参数:
x
- the x coordinate of the centery
- the y coordinate of the centerradius
- the radius of the circle- 返回:
- a new Circle object
-
createRectangle
Create a rectangle with the specified parameters- 参数:
x
- the x coordinate of the top-left cornery
- the y coordinate of the top-left cornerwidth
- the width of the rectangleheight
- the height of the rectangle- 返回:
- a new Rectangle object
-
createLine
Create a line with the specified endpoints- 参数:
x1
- the x coordinate of the first endpointy1
- the y coordinate of the first endpointx2
- the x coordinate of the second endpointy2
- the y coordinate of the second endpoint- 返回:
- a new Line object
-
createTriangle
Create a triangle with the specified vertices- 参数:
x1
- the x coordinate of the first vertexy1
- the y coordinate of the first vertexx2
- the x coordinate of the second vertexy2
- the y coordinate of the second vertexx3
- the x coordinate of the third vertexy3
- the y coordinate of the third vertex- 返回:
- a new Triangle object
-