Browse Source

Factory design pattern test.

pull/50/head
Rafal Kupiec 2 years ago
parent
commit
9c426b20cc
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
2 changed files with 31 additions and 0 deletions
  1. +29
    -0
      tests/factory_objects.aer
  2. +2
    -0
      tests/factory_objects.exp

+ 29
- 0
tests/factory_objects.aer 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();
}
}

+ 2
- 0
tests/factory_objects.exp View File

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

Loading…
Cancel
Save