Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changes between Version 3 and Version 4 of DecoratorPattern

Show
Ignore:
Author:
darkzlayer (IP: 121.54.2.82)
Timestamp:
06/14/10 11:04:19 (14 years ago)
Comment:

no need for pointers and reference in OOP

Legend:

Unmodified
Added
Removed
Modified
  • DecoratorPattern

    v3 v4  
    3636        } 
    3737         
    38         ~this() { } 
    39          
    4038        void attack(Player u) { 
    4139                writefln("Target: " ~ u.toString()); 
    6058        } 
    6159         
    62         ~this() { } 
    63          
    6460        string toString() { // string representation of this class 
    6561                return super.getName(); 
    7874        } 
    7975         
    80         ~this() { } 
    81          
    8276        string toString() { // string representation of this class 
    8377                return super.getName(); 
    9084        private Unit wrapperObj; 
    9185         
    92         this(Unit* u) { 
    93                 this.wrapperObj = *u; 
     86        this(Unit u) { 
     87                this.wrapperObj = u; 
    9488        } 
    95          
    96         ~this() { } 
    9789         
    9890        void attack(Player u) { 
    108100         
    109101         
    110         this(Unit* u) { 
    111                 this.wrapperObj = *u; 
     102        this(Unit u) { 
     103                this.wrapperObj = u; 
    112104        } 
    113105         
    124116        Unit player = new Knight("Arth"); // the attacker 
    125117         
    126         player = new Bash(&player); // decorated attack 
    127         player = new ChainLightning(&player); // decorated attack umm... err btw does knight have a chain lightning? 
     118        player = new Bash(player); // decorated attack 
     119        player = new ChainLightning(player); // decorated attack umm... err btw does knight have a chain lightning? 
    128120         
    129121        player.attack(new Assassin("Lloyd"));  // the target