Typehinting merge #50
29
tests/factory_objects.aer
Normal file
29
tests/factory_objects.aer
Normal 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
tests/factory_objects.exp
Normal file
2
tests/factory_objects.exp
Normal file
@ -0,0 +1,2 @@
|
||||
Circle
|
||||
Square
|
Loading…
Reference in New Issue
Block a user