Football Tactics -> Interpreter

zhaozj2021-02-11  170

Connect to:

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

Using the Interpreter mode when the troops quarter, let the coach do not need to go to HACK, but simple reuse can complete complex tactics. In this mode, the client is a coach. Context is a team. AbstractExpression is a basic play. TerminalExpression is a playing method of a single player. Or extension; and the implementation of the classes of each node in the "Abstract Tree" is substantially similar, easy to achieve. The disadvantage is to define a class for each play, it is difficult to maintain when playing is very complicated. Interpreter and Composite (combined offensive) have a lot of communication in achieving, the following is a special problem that needs to be considered: 1. Abstract playing tree creation. You can use the play of the classic textbook, or may be provided by the coach. 2. The implementation of the play can be implemented using Visitor. 3. When many play is a final completion, this player can share as Flyweight :) The code is as follows: Class Basic play {public: Basic play (); Virtual ~ Basic play ();

Virtual BOOL (Team &) = 0; Virtual Basic Play * Offense (Const Char *, Basic Play &) = 0; Virtual Basic Play * Defense (Const Char *, Basic Play &) = 0;} ;

Class team {public: Bool finds a player (const char *) const; void assignment (player playing *, bool);

Class Left Backward Play: Public Basic Play {Public: Left Rand Guard Play (Const Char *); Virtual ~ Left Raffle Play ();

Virtual Bool (Team &); Virtual Basic Play * Attack (Const Char *, Basic Play &); Virtual Basic Play * Defense (Const Char *, Bas Playing &); Private: char * _ left back number;};

Class Double Force Tale: Public Basic Play {Public: Double Forward Tripement (Basic Play *, Basic Play *); Virtual ~ Double Forveling ();

Virtual Bool Organization (Team &); Virtual Basic Play * Attack (Const Char *, Basic Play &); Virtual Basic Play * Defense (Const Char *, Basic Play &); Private: Basic Play * Front front; basic play * _ forward B;

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

New Post(0)