Factory method articles of football tactics

zhaozj2021-02-11  177

Connect to:

http://www.9cbs.net/develop/read_article.asp?id=12040

The use of factory methods have the following benefits, players only processes the PRODUCT interface, but every time you have a new goal, you must let this player to learn this method, or change a team member. The player base class creates a goal in the class instead of being created directly, providing a hook for the subclass. Provide parallel class level. The code is as follows: Class player {public: Virtual goal * Create (scientific type);

Goal * Players :: Create (Id Type ID) {IF (ID == High Empty Ball) Return New Headball Entire; IF (ID == Half Globe) Return New Pumping Drake; File: // Repeat For Remaining Products ... returnography;}

Goal * Time Machine :: Created (Id) {IF (ID == High Empty Ball) Return New Ball Hook; if (ID == Half-High Ball) Return New Chest or Shoulder Shift; if (ID == Low-ball) Return New fishing top; Return player :: Create (ID); // Call when all other failures}

转载请注明原文地址:https://www.9cbs.com/read-5221.html

New Post(0)