boss_factorz- - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of boss_factorz-.php
- <?php
- abstract class ApptEncoder
- {
- abstract public function encode(): string;
- }
- // listing 09.14
- class BloggsApptEncoder extends ApptEncoder
- {
- public function encode(): string
- {
- return "Appointment data encoded in BloggsCal format\n";
- }
- }
- // listing 09.15
- class MegaApptEncoder extends ApptEncoder
- {
- public function encode(): string
- {
- return "Appointment data encoded in MegaCal format\n";
- }
- }
- class CommsManager
- {
- const BLOGGS = 1;
- const MEGA = 2;
- private $mode;
- public function __construct(int $mode)
- {
- $this->mode = $mode;
- }
- public function getApptEncoder(): ApptEncoder
- {
- switch ($this->mode) {
- case (self::MEGA):
- return new MegaApptEncoder();
- default:
- return new BloggsApptEncoder();
- }
- }
- }
- // listing 09.18
- $man = new CommsManager(CommsManager::MEGA);
- print (get_class($man->getApptEncoder())) . "\n";
- $man = new CommsManager(CommsManager::BLOGGS);
- print (get_class($man->getApptEncoder())) . "\n";
File Description
- boss_factorz-
- PHP Code
- 20 Mar-2021
- 904 Bytes
You can Share it:
Latest PHP Pastes