<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>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ### 概述 將一個類的接口轉換成可應用的兼容接口。適配器使原本由于接口不兼容而不能一起工作的那些類可以一起工作。 ### 實例 ~~~ interface BookInterface{ public function open(); public function turnPage(); public function getPage(); } class Book implements BookInterface{ private $page; public function open() { $this->page = 1; } public function turnPage() { $this->page++; } public function getPage():int { return $this->page; } } interface EBookInterface { public function unlock(); public function pressNext(); public function getPage(); } class Kindle implements EBookInterface{ private $page = 1; private $totalPages = 100; public function unlock() { } public function pressNext() { $this->page++; } public function getPage():array { return [$this->page,$this->totalPages]; } } class EBookAdapter implements BookInterface{ private $eBook; public function __construct(EBookInterface $eBook) { $this->eBook = $eBook; } public function open() { $this->eBook->unlock(); } public function turnPage() { $this->eBook->pressNext(); } public function getPage():int { return $this->eBook->getPage()[0]; } } $book = new Book(); $book->open(); $book->turnPage(); var_dump($book->getPage()); $kindle = new Kindle(); $book = new EBookAdapter($kindle); $book->open(); $book->turnPage(); $book->turnPage(); $book->turnPage(); var_dump($book->getPage()); ~~~ 結果 ~~~ 2 4 ~~~
                  <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>

                              哎呀哎呀视频在线观看