30 lines
425 B
Plaintext
30 lines
425 B
Plaintext
class Circle {
|
|
public void draw() {
|
|
print("Circle\n");
|
|
}
|
|
}
|
|
|
|
class Square {
|
|
public void draw() {
|
|
print("Square\n");
|
|
}
|
|
}
|
|
|
|
class Program {
|
|
|
|
object ShapeFactoryMethod(string $shape) {
|
|
switch ($shape) {
|
|
case "Circle":
|
|
return new Circle();
|
|
case "Square":
|
|
return new Square();
|
|
}
|
|
}
|
|
|
|
public void main() {
|
|
$this->ShapeFactoryMethod("Circle")->draw();
|
|
$this->ShapeFactoryMethod("Square")->draw();
|
|
}
|
|
|
|
}
|