Factory method Mode

Source: Internet
Author: User

<?PHP//BT Seed InterfaceInterfacebt{ Public functionprocess ();}//download processing class for BT seedsclassBtdownImplementsbt{ Public functionprocess () {//Output BT seeds        Echo' Output BT seeds '; }}//BT seed upload processing classclassBtuploadImplementsbt{ Public functionprocess () {//Save the uploaded bt seeds        Echo' Save the uploaded bt Seeds '; }}//interface of equipment for producing BT seed processing objectsInterfacebtcreator{ Public functioncreatebtobject ();}//equipment for the production of BT seed download processing objectsclassBtdowncreatorImplementsbtcreator{ Public functionCreatebtobject () {/** * If not an administrator, send 10 points*/        //then return to the BT seed download processing Object        return NewBtdown (); }}//equipment for the production of BT seed upload processing objectsclassBtuploadcreatorImplementsbtcreator{ Public functionCreatebtobject () {/** * If not an administrator, send 10 points*/        //then return to the BT seed download processing Object        return Newbtupload (); }}//factories that produce BT seed processing objectsclassbtfactory{//gets the object for the movie processing class, with the parameter class name     Public functionGetbtobject ($name)    {        Switch($name) {             Case' Btdown ':$creator=NewBtdowncreator ();  Break;  Case' Btupload ':$creator=NewBtuploadcreator ();  Break; }        return $creator-Createbtobject (); }}//Get BT Factory$btFactory=Newbtfactory ();//download and processing of BT seeds$what= ' Btdown ';$btObject=$btFactory->getbtobject ($what);$btObject-process ();//uploading and processing of BT seeds$what= ' Btupload ';$btObject=$btFactory->getbtobject ($what);$btObject-process ();?>

Factory method Mode

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.