29
tests/factory_objects.aer
一般檔案
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
一般檔案
2
tests/factory_objects.exp
一般檔案
@@ -0,0 +1,2 @@
|
||||
Circle
|
||||
Square
|
||||
新增問題並參考
封鎖使用者