From d39bfe6a694b6ef36b57838dc6a84c4bbe992c72 Mon Sep 17 00:00:00 2001 From: "farhanjk@gmail.com" Date: Fri, 3 Jan 2014 20:18:00 -0400 Subject: [PATCH] Added decorator --- README.md | 2 +- structural/decorator/decorator_main | Bin 0 -> 14888 bytes structural/decorator/decorator_main.f90 | 35 +++++++++++++ structural/decorator/decorator_module.f90 | 61 ++++++++++++++++++++++ 4 files changed, 97 insertions(+), 1 deletion(-) create mode 100755 structural/decorator/decorator_main create mode 100644 structural/decorator/decorator_main.f90 diff --git a/README.md b/README.md index 4135831..d06bf9f 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Tested on: GNU Fortran (GCC) 4.8. - [X] Bridge - [X] Composite - [X] Criteria -- [ ] Decorator +- [X] Decorator - [ ] Façade - [ ] Flyweight - [ ] Proxy diff --git a/structural/decorator/decorator_main b/structural/decorator/decorator_main new file mode 100755 index 0000000000000000000000000000000000000000..257ff42eb76443a421cf33f30d17dc8cf197adf0 GIT binary patch literal 14888 zcmeHOeQX@X6`#BFCWd?+fs~MxvY@1dra9YjoP@Nl&WTM9kr2lpDD*>{^W8eW_Izjd z)=5kYHH8Z~jzdNwMM^(N`XLGeL8DMmL>miG4UJM##7C=E$Za89T2LbdRhkCe-nBm(gi z|4K#E^ggZE2>0tk!;R(afy4Z=4LmQBr*%TO_B;dZvX6kY18#L-q6;1y|t$Ro$FeT@!qiaTqtm89-LTLVc+8_IFX4T z^+KV_&&$A{2DPw(v1edN{*k<|kueqZGfj*QVBj>j?Kr5=+M&ab<5M_f*Pu#EAM7tF zZDw=Prs9~5qi!%|)Wu^xb1zJb%%;Czh z5agP!;#G4es%OZTypCtbqx6)JPlG}aegSlW1bV;;G&_`Q4#G5l4e92T5AeVNlegz^ z?j&*9;KERL!7*ydydKK@W8wt#8mQMyy7uFViLtaF=LP6+EX_a-bE*auJzR!zyfKs+ z%fAU;vPY0kBIkAFE=csUEh6>^u~|i?{ili;iKoxDZ=*<@+wyNF6E9ikw+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ircle + end type circle + + type, extends(shape), abstract :: shapeDecorator + end type shapeDecorator + + type, extends(shapeDecorator) :: redShapeDecorator + class(shape), pointer :: decoratedShape + contains + procedure :: draw => drawWithRedShapeDecorator + end type redShapeDecorator + +contains + + subroutine drawRectangle(this) + class(rectangle), intent(in) :: this + print *, "Draw rectangle" + end subroutine + + subroutine drawCircle(this) + class(circle), intent(in) :: this + print *, "Draw circle" + end subroutine + + subroutine drawWithRedShapeDecorator(this) + class(redShapeDecorator), intent(in) :: this + call this%decoratedShape%draw + print *, "Red Border" + end subroutine + +end module decorator_module \ No newline at end of file