Changes between Version 2 and Version 3 of CompositePattern
- Timestamp:
- 08/23/07 18:53:04 (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CompositePattern
v2 v3 13 13 import std.stdio; 14 14 15 interface GraphicsOperation /* Component */ {15 interface IGraphicsOperation /* Component */ { 16 16 void print(); 17 17 } 18 18 19 class Circle /* Leaf */ : GraphicsOperation {19 class Circle /* Leaf */ : IGraphicsOperation { 20 20 void print() {writefln("Circle");} 21 21 } 22 22 23 class Line /* Leaf */ : GraphicsOperation {23 class Line /* Leaf */ : IGraphicsOperation { 24 24 void print() {writefln("Line");} 25 25 } 26 26 27 class Drawing /* Composite */ : GraphicsOperation {28 GraphicsOperation[] children;27 class Drawing /* Composite */ : IGraphicsOperation { 28 IGraphicsOperation[] children; 29 29 30 30 void print() { 34 34 } 35 35 36 void add( GraphicsOperation c) {36 void add(IGraphicsOperation c) { 37 37 children~=c; 38 38 } 39 39 40 void remove( GraphicsOperation c) {40 void remove(IGraphicsOperation c) { 41 41 for(uint i=0; i<children.length; i++) { 42 42 if (children[i] == c) {