Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
DECORATOR
НАЗНАЧЕНИЕ 
Динамически порождает объекты
СТРУКТУРА
РЕАЛИЗАЦИЯ 
ABSTRACT CLASS COMPONENT 
{ 
PUBLIC ABSTRACT VOID DRAW(); 
}
РЕАЛИЗАЦИЯ 
CLASS CONCRETECOMPONENT : COMPONENT 
{ 
PUBLIC OVERRIDE VOID DRAW() 
{ 
} 
}
РЕАЛИЗАЦИЯ 
ABSTRACT CLASS DECORATOR : COMPONENT 
{ 
PROTECTED COMPONENT COMPONENT; 
PUBLIC VOID SETCOMPONENT(COMPONENT COMPONENT) 
{ 
THIS.COMPONENT = COMPONENT; 
} 
PUBLIC OVERRIDE VOID DRAW() 
{ 
IF (COMPONENT != NULL) 
{ 
COMPONENT.DRAW(); 
} 
} 
}
РЕАЛИЗАЦИЯ 
CLASS SCROLLDECORATOR : DECORATOR 
{ 
PUBLIC OVERRIDE VOID DRAW() 
{ 
BASE.DRAW(); 
SCROLLTO(); 
} 
PRIVATE VOID SCROLLTO() 
{ 
} 
}
РЕАЛИЗАЦИЯ 
CLASS BORDERDECORATOR : DECORATOR 
{ 
PUBLIC OVERRIDE VOID DRAW() 
{ 
BASE.DRAW(); 
DRAWBORDER(); 
} 
PRIVATE VOID DRAWBORDER() 
{ 
} 
}
РЕАЛИЗАЦИЯ 
// CREATE CONCRETECOMPONENT AND TWO DECORATORS 
CONCRETECOMPONENT TEXTVIEW = NEW CONCRETECOMPONENT(); 
SCROLLDECORATOR SCROLLDECORATOR = NEW SCROLLDECORATOR(); 
BORDERDECORATOR BORDERDECORATOR = NEW BORDERDECORATOR(); 
// LINK DECORATORS 
SCROLLDECORATOR.SETCOMPONENT(TEXTVIEW); 
BORDERDECORATOR.SETCOMPONENT(SCROLLDECORATOR); 
SCROLLDECORATOR.DRAW(); 
BORDERDECORATOR.DRAW();

More Related Content

test title