Changes between Version 3 and Version 4 of DecoratorPattern
- Timestamp:
- 06/14/10 11:04:19 (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DecoratorPattern
v3 v4 36 36 } 37 37 38 ~this() { }39 40 38 void attack(Player u) { 41 39 writefln("Target: " ~ u.toString()); 60 58 } 61 59 62 ~this() { }63 64 60 string toString() { // string representation of this class 65 61 return super.getName(); 78 74 } 79 75 80 ~this() { }81 82 76 string toString() { // string representation of this class 83 77 return super.getName(); 90 84 private Unit wrapperObj; 91 85 92 this(Unit *u) {93 this.wrapperObj = *u;86 this(Unit u) { 87 this.wrapperObj = u; 94 88 } 95 96 ~this() { }97 89 98 90 void attack(Player u) { 108 100 109 101 110 this(Unit *u) {111 this.wrapperObj = *u;102 this(Unit u) { 103 this.wrapperObj = u; 112 104 } 113 105 124 116 Unit player = new Knight("Arth"); // the attacker 125 117 126 player = new Bash( &player); // decorated attack127 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? 128 120 129 121 player.attack(new Assassin("Lloyd")); // the target