Factory design pattern test.
已通過所有檢查
The build was successful.

此提交包含在:
2019-04-10 20:22:13 +02:00
父節點 725b60cb88
當前提交 9c426b20cc
共有 2 個檔案被更改,包括 31 行新增0 行删除

29
tests/factory_objects.aer 一般檔案
查看文件

@@ -0,0 +1,29 @@
class Circle {
void draw() {
print("Circle\n");
}
}
class Square {
void draw() {
print("Square\n");
}
}
class Program {
object ShapeFactoryMethod(string $shape) {
switch ($shape) {
case "Circle":
return new Circle();
case "Square":
return new Square();
}
}
void main() {
$this->ShapeFactoryMethod("Circle")->draw();
$this->ShapeFactoryMethod("Square")->draw();
}
}

2
tests/factory_objects.exp 一般檔案
查看文件

@@ -0,0 +1,2 @@
Circle
Square