belliash
55acf8111f
All checks were successful
The build was successful.
In most (all?) modern OOP languages class members visibility is assumed to be private and programmer has to consciously set it to public or protected. PHP has the different approach what can cause a security flaws in written scripts. AerScript will not follow this way, as it seems to be conceptually broken.
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();
|
|
}
|
|
|
|
}
|