Factory design pattern test.
The build was successful.
Details
The build was successful.
Details
This commit is contained in:
parent
725b60cb88
commit
9c426b20cc
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
Circle
|
||||
Square
|
Loading…
Reference in New Issue