<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                [TOC] ## 示例 ### 概念示例 <details> <summary>index.php</summary> ``` <?php interface Product{ public function operation():string; } class Product1 implements Product{ public function operation():string{ return "Product1\n"; } } class Product2 implements Product{ public function operation():string{ return "Product2\n"; } } abstract class Creator{ abstract public function factoryProduct():Product; public function operation():string{ $product = $this->factoryProduct(); return $product->operation(); } } class CreatorProduct1 extends Creator{ public function factoryProduct():Product{ return new Product1(); } } class CreatorProduct2 extends Creator{ public function factoryProduct():Product{ return new Product2(); } } function clientCode(Creator $create){ $product = $create->factoryProduct(); echo $product->operation(); } clientCode(new CreatorProduct1()); //Product1 clientCode(new CreatorProduct2()); // Product2 ``` </details> <br /> ### 社交網絡連接器 <details> <summary>index.php</summary> ``` <?php abstract class SocialNetworkPoster { abstract public function getSocialNetwork(): SocialNetworkConnector; public function post($content): void { $network = $this->getSocialNetwork(); // ...then use it as you will. $network->logIn(); $network->createPost($content); $network->logout(); } } class FacebookPoster extends SocialNetworkPoster { private $login, $password; public function __construct(string $login, string $password) { $this->login = $login; $this->password = $password; } public function getSocialNetwork(): SocialNetworkConnector { return new FacebookConnector($this->login, $this->password); } } // LinkedIn class LinkedInPoster extends SocialNetworkPoster { private $email, $password; public function __construct(string $email, string $password) { $this->email = $email; $this->password = $password; } public function getSocialNetwork(): SocialNetworkConnector { return new LinkedInConnector($this->email, $this->password); } } interface SocialNetworkConnector { public function logIn(): void; public function logOut(): void; public function createPost($content): void; } class FacebookConnector implements SocialNetworkConnector { private $login, $password; public function __construct(string $login, string $password) { $this->login = $login; $this->password = $password; } public function logIn(): void { echo "logIn:$this->login with password $this->password \n"; } public function logOut(): void { echo "logOut:$this->login\n\n"; } public function createPost($content): void { echo "createPost:{$content}\n"; } } class LinkedInConnector implements SocialNetworkConnector { private $email, $password; public function __construct(string $email, string $password) { $this->email = $email; $this->password = $password; } public function logIn(): void { echo "logIn: $this->email $this->password\n"; } public function logOut(): void { echo "logOut: $this->email\n\n"; } public function createPost($content): void { echo "createPost: $content\n"; } } function clientCode(SocialNetworkPoster $creator) { // ... $creator->post("Hello world!"); $creator->post("I had a large hamburger this morning!"); // ... } clientCode(new FacebookPoster("john_smith", "******")); echo "\n\n"; clientCode(new LinkedInPoster("john_smith@example.com", "******")); ``` </details> <br />
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看