31 lines
461 B
Plaintext
31 lines
461 B
Plaintext
import 'console';
|
|
class Circle {
|
|
public void draw() {
|
|
Console::Print("Circle\n");
|
|
}
|
|
}
|
|
|
|
class Square {
|
|
public void draw() {
|
|
Console::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();
|
|
}
|
|
|
|
}
|