Factory design pattern test.
The build was successful. Details

This commit is contained in:
Rafal Kupiec 2019-04-10 20:22:13 +02:00
parent 725b60cb88
commit 9c426b20cc
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
2 changed files with 31 additions and 0 deletions

29
tests/factory_objects.aer Normal file
View File

@ -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();
}
}

View File

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