From 526ebc27303078734cfc7064cc23bd79c8032f3d Mon Sep 17 00:00:00 2001 From: RenPeng Date: Wed, 31 Aug 2016 16:47:31 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=96=B0=E5=A2=9E=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=EF=BC=9A=E8=AE=BF=E9=97=AE=E8=80=85=E3=80=81?= =?UTF-8?q?=E8=A7=A3=E9=87=8A=E5=99=A8=E3=80=81=E4=B8=AD=E4=BB=8B=E8=80=85?= =?UTF-8?q?=E3=80=81=E4=BA=AB=E5=85=83=E3=80=81=E8=81=8C=E8=B4=A3=E9=93=BE?= =?UTF-8?q?=E3=80=81=E5=91=BD=E4=BB=A4=E3=80=81=E8=BF=AD=E4=BB=A3=E5=99=A8?= =?UTF-8?q?=E3=80=81=E7=BB=84=E5=90=88=E3=80=81=E5=A4=87=E5=BF=98=E5=BD=95?= =?UTF-8?q?=E3=80=81=E9=80=82=E9=85=8D=E5=99=A8=E3=80=81=E8=A7=82=E5=AF=9F?= =?UTF-8?q?=E8=80=85=E3=80=81=E8=A3=85=E9=A5=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DesignPatterns.xcodeproj/project.pbxproj | 552 +++++++++++++++++- .../Center.h" | 13 + .../Center.m" | 32 + .../ForeignCenter.h" | 19 + .../ForeignCenter.m" | 28 + .../Forwards.h" | 18 + .../Forwards.m" | 32 + .../Guards.h" | 13 + .../Guards.m" | 32 + .../Player.h" | 18 + .../Player.m" | 33 ++ .../Translator.h" | 15 + .../Translator.m" | 42 ++ .../ChainOfResponsibility/CommonManager.h | 15 + .../ChainOfResponsibility/CommonManager.m | 33 ++ .../ChainOfResponsibility/GeneralManager.h | 14 + .../ChainOfResponsibility/GeneralManager.m | 40 ++ .../ChainOfResponsibility/Majordomo.h | 14 + .../ChainOfResponsibility/Majordomo.m | 32 + .../ChainOfResponsibility/Manager.h | 19 + .../ChainOfResponsibility/Manager.m | 21 + .../ChainOfResponsibility/Request.h | 29 + .../ChainOfResponsibility/Request.m | 21 + .../Command/BakeChickenWingCommand.h | 15 + .../Command/BakeChickenWingCommand.m | 29 + DesignPatterns/Command/BakeMuttonCommand.h | 17 + DesignPatterns/Command/BakeMuttonCommand.m | 30 + DesignPatterns/Command/Barbecuer.h | 16 + DesignPatterns/Command/Barbecuer.m | 18 + DesignPatterns/Command/Command.h | 15 + DesignPatterns/Command/Waiter.h | 17 + DesignPatterns/Command/Waiter.m | 50 ++ .../Component.h" | 21 + .../Component.m" | 33 ++ .../Composite.h" | 14 + .../Composite.m" | 51 ++ .../Composite\347\273\204\345\220\210/Leaf.h" | 16 + .../Composite\347\273\204\345\220\210/Leaf.m" | 36 ++ .../BigTrouser.h" | 13 + .../BigTrouser.m" | 19 + .../Finery.h" | 19 + .../Finery.m" | 46 ++ .../Person.h" | 22 + .../Person.m" | 31 + .../TShirts.h" | 13 + .../TShirts.m" | 18 + DesignPatterns/Flyweight/ConcerteWebSite.h | 13 + DesignPatterns/Flyweight/ConcerteWebSite.m | 29 + DesignPatterns/Flyweight/FlyweightUser.h | 17 + DesignPatterns/Flyweight/FlyweightUser.m | 26 + DesignPatterns/Flyweight/WebSite.h | 13 + DesignPatterns/Flyweight/WebSiteFactory.h | 21 + DesignPatterns/Flyweight/WebSiteFactory.m | 37 ++ .../Expression.h" | 16 + .../Expression.m" | 28 + .../Note.h" | 13 + .../Note.m" | 35 ++ .../PlayContext.h" | 13 + .../PlayContext.m" | 13 + .../Scale.h" | 13 + .../Scale.m" | 31 + .../Aggregate.h" | 16 + .../ConcreteAggregate.h" | 19 + .../ConcreteAggregate.m" | 39 ++ .../ConcreteIterator.h" | 17 + .../ConcreteIterator.m" | 49 ++ .../Iterator.h" | 18 + .../Country.h" | 17 + .../Country.m" | 20 + .../Iraq.h" | 14 + .../Iraq.m" | 18 + .../USA.h" | 15 + .../USA.m" | 18 + .../UnitedNations.h" | 16 + .../UnitedNationsSecurityCouncil.h" | 16 + .../UnitedNationsSecurityCouncil.m" | 24 + .../GameRole.h" | 27 + .../GameRole.m" | 48 ++ .../RoleStateCaretaker.h" | 21 + .../RoleStateCaretaker.m" | 23 + .../RoleStateMemento.h" | 22 + .../RoleStateMemento.m" | 23 + .../ConcreteObserver.h" | 18 + .../ConcreteObserver.m" | 35 ++ .../ConcreteSubject.h" | 15 + .../ConcreteSubject.m" | 13 + .../Observe.h" | 15 + .../Subject.h" | 17 + .../Subject.m" | 36 ++ .../Action.h" | 20 + .../Amativeness.h" | 14 + .../Amativeness.m" | 21 + .../Failing.h" | 14 + .../Failing.m" | 21 + .../Man.h" | 14 + .../Man.m" | 18 + .../ObjectStructure.h" | 19 + .../ObjectStructure.m" | 39 ++ .../Success.h" | 14 + .../Success.m" | 21 + .../VisitorPerson.h" | 16 + .../Woman.h" | 13 + .../Woman.m" | 18 + .../Adapter.m" | 48 ++ .../ChainOfResponsibility.m | 60 ++ .../Command.m" | 52 ++ .../CompositeTest.m" | 61 ++ .../Decorator.m" | 37 ++ DesignPatternsTests/Flyweight/Flyweight.m | 44 ++ .../Interpreter.m" | 47 ++ .../Iterator.m" | 51 ++ .../Mediator.m" | 45 ++ .../Memento.m" | 54 ++ .../Observe.m" | 46 ++ .../Visitor.m" | 56 ++ 115 files changed, 3447 insertions(+), 7 deletions(-) create mode 100644 "DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Center.h" create mode 100644 "DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Center.m" create mode 100644 "DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/ForeignCenter.h" create mode 100644 "DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/ForeignCenter.m" create mode 100644 "DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Forwards.h" create mode 100644 "DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Forwards.m" create mode 100644 "DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Guards.h" create mode 100644 "DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Guards.m" create mode 100644 "DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Player.h" create mode 100644 "DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Player.m" create mode 100644 "DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Translator.h" create mode 100644 "DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Translator.m" create mode 100644 DesignPatterns/ChainOfResponsibility/CommonManager.h create mode 100644 DesignPatterns/ChainOfResponsibility/CommonManager.m create mode 100644 DesignPatterns/ChainOfResponsibility/GeneralManager.h create mode 100644 DesignPatterns/ChainOfResponsibility/GeneralManager.m create mode 100644 DesignPatterns/ChainOfResponsibility/Majordomo.h create mode 100644 DesignPatterns/ChainOfResponsibility/Majordomo.m create mode 100644 DesignPatterns/ChainOfResponsibility/Manager.h create mode 100644 DesignPatterns/ChainOfResponsibility/Manager.m create mode 100644 DesignPatterns/ChainOfResponsibility/Request.h create mode 100644 DesignPatterns/ChainOfResponsibility/Request.m create mode 100644 DesignPatterns/Command/BakeChickenWingCommand.h create mode 100644 DesignPatterns/Command/BakeChickenWingCommand.m create mode 100644 DesignPatterns/Command/BakeMuttonCommand.h create mode 100644 DesignPatterns/Command/BakeMuttonCommand.m create mode 100644 DesignPatterns/Command/Barbecuer.h create mode 100644 DesignPatterns/Command/Barbecuer.m create mode 100644 DesignPatterns/Command/Command.h create mode 100644 DesignPatterns/Command/Waiter.h create mode 100644 DesignPatterns/Command/Waiter.m create mode 100644 "DesignPatterns/Composite\347\273\204\345\220\210/Component.h" create mode 100644 "DesignPatterns/Composite\347\273\204\345\220\210/Component.m" create mode 100644 "DesignPatterns/Composite\347\273\204\345\220\210/Composite.h" create mode 100644 "DesignPatterns/Composite\347\273\204\345\220\210/Composite.m" create mode 100644 "DesignPatterns/Composite\347\273\204\345\220\210/Leaf.h" create mode 100644 "DesignPatterns/Composite\347\273\204\345\220\210/Leaf.m" create mode 100644 "DesignPatterns/Decorator\350\243\205\351\245\260/BigTrouser.h" create mode 100644 "DesignPatterns/Decorator\350\243\205\351\245\260/BigTrouser.m" create mode 100644 "DesignPatterns/Decorator\350\243\205\351\245\260/Finery.h" create mode 100644 "DesignPatterns/Decorator\350\243\205\351\245\260/Finery.m" create mode 100644 "DesignPatterns/Decorator\350\243\205\351\245\260/Person.h" create mode 100644 "DesignPatterns/Decorator\350\243\205\351\245\260/Person.m" create mode 100644 "DesignPatterns/Decorator\350\243\205\351\245\260/TShirts.h" create mode 100644 "DesignPatterns/Decorator\350\243\205\351\245\260/TShirts.m" create mode 100644 DesignPatterns/Flyweight/ConcerteWebSite.h create mode 100644 DesignPatterns/Flyweight/ConcerteWebSite.m create mode 100644 DesignPatterns/Flyweight/FlyweightUser.h create mode 100644 DesignPatterns/Flyweight/FlyweightUser.m create mode 100644 DesignPatterns/Flyweight/WebSite.h create mode 100644 DesignPatterns/Flyweight/WebSiteFactory.h create mode 100644 DesignPatterns/Flyweight/WebSiteFactory.m create mode 100644 "DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Expression.h" create mode 100644 "DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Expression.m" create mode 100644 "DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Note.h" create mode 100644 "DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Note.m" create mode 100644 "DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/PlayContext.h" create mode 100644 "DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/PlayContext.m" create mode 100644 "DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Scale.h" create mode 100644 "DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Scale.m" create mode 100644 "DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/Aggregate.h" create mode 100644 "DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/ConcreteAggregate.h" create mode 100644 "DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/ConcreteAggregate.m" create mode 100644 "DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/ConcreteIterator.h" create mode 100644 "DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/ConcreteIterator.m" create mode 100644 "DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/Iterator.h" create mode 100644 "DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/Country.h" create mode 100644 "DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/Country.m" create mode 100644 "DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/Iraq.h" create mode 100644 "DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/Iraq.m" create mode 100644 "DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/USA.h" create mode 100644 "DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/USA.m" create mode 100644 "DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/UnitedNations.h" create mode 100644 "DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/UnitedNationsSecurityCouncil.h" create mode 100644 "DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/UnitedNationsSecurityCouncil.m" create mode 100644 "DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/GameRole.h" create mode 100644 "DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/GameRole.m" create mode 100644 "DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/RoleStateCaretaker.h" create mode 100644 "DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/RoleStateCaretaker.m" create mode 100644 "DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/RoleStateMemento.h" create mode 100644 "DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/RoleStateMemento.m" create mode 100644 "DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/ConcreteObserver.h" create mode 100644 "DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/ConcreteObserver.m" create mode 100644 "DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/ConcreteSubject.h" create mode 100644 "DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/ConcreteSubject.m" create mode 100644 "DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/Observe.h" create mode 100644 "DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/Subject.h" create mode 100644 "DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/Subject.m" create mode 100644 "DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Action.h" create mode 100644 "DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Amativeness.h" create mode 100644 "DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Amativeness.m" create mode 100644 "DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Failing.h" create mode 100644 "DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Failing.m" create mode 100644 "DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Man.h" create mode 100644 "DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Man.m" create mode 100644 "DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/ObjectStructure.h" create mode 100644 "DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/ObjectStructure.m" create mode 100644 "DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Success.h" create mode 100644 "DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Success.m" create mode 100644 "DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/VisitorPerson.h" create mode 100644 "DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Woman.h" create mode 100644 "DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Woman.m" create mode 100644 "DesignPatternsTests/Adapter\351\200\202\351\205\215\345\231\250/Adapter.m" create mode 100644 DesignPatternsTests/ChainOfResponsibility/ChainOfResponsibility.m create mode 100644 "DesignPatternsTests/Command\345\221\275\344\273\244/Command.m" create mode 100644 "DesignPatternsTests/Composite\347\273\204\345\220\210/CompositeTest.m" create mode 100644 "DesignPatternsTests/Decorator\350\243\205\351\245\260/Decorator.m" create mode 100644 DesignPatternsTests/Flyweight/Flyweight.m create mode 100644 "DesignPatternsTests/Interpreter\350\247\243\351\207\212\345\231\250/Interpreter.m" create mode 100644 "DesignPatternsTests/Iterator\350\277\255\344\273\243\345\231\250/Iterator.m" create mode 100644 "DesignPatternsTests/Mediator\344\270\255\344\273\213\350\200\205/Mediator.m" create mode 100644 "DesignPatternsTests/Memento\345\244\207\345\277\230\345\275\225/Memento.m" create mode 100644 "DesignPatternsTests/Observe\350\247\202\345\257\237\350\200\205/Observe.m" create mode 100644 "DesignPatternsTests/Visitor\350\256\277\351\227\256\350\200\205/Visitor.m" diff --git a/DesignPatterns.xcodeproj/project.pbxproj b/DesignPatterns.xcodeproj/project.pbxproj index 0bb048f..d662462 100644 --- a/DesignPatterns.xcodeproj/project.pbxproj +++ b/DesignPatterns.xcodeproj/project.pbxproj @@ -84,6 +84,65 @@ 24B2B0841A067DB1001D74E0 /* BuilderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 24B2B0831A067DB1001D74E0 /* BuilderTests.m */; }; 24BD698A1A4477170007D525 /* PrototypeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 24BD69891A4477170007D525 /* PrototypeTests.m */; }; 24D9588419FE99B800C3F23E /* StateTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 24D9588319FE99B800C3F23E /* StateTests.m */; }; + F9E5D4B31D76CF04009F107B /* Center.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4A81D76CF04009F107B /* Center.m */; }; + F9E5D4B41D76CF04009F107B /* ForeignCenter.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4AA1D76CF04009F107B /* ForeignCenter.m */; }; + F9E5D4B51D76CF04009F107B /* Forwards.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4AC1D76CF04009F107B /* Forwards.m */; }; + F9E5D4B61D76CF04009F107B /* Guards.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4AE1D76CF04009F107B /* Guards.m */; }; + F9E5D4B71D76CF04009F107B /* Player.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4B01D76CF04009F107B /* Player.m */; }; + F9E5D4B81D76CF04009F107B /* Translator.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4B21D76CF04009F107B /* Translator.m */; }; + F9E5D4DE1D76CF16009F107B /* CommonManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4BB1D76CF16009F107B /* CommonManager.m */; }; + F9E5D4DF1D76CF16009F107B /* GeneralManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4BD1D76CF16009F107B /* GeneralManager.m */; }; + F9E5D4E01D76CF16009F107B /* Majordomo.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4BF1D76CF16009F107B /* Majordomo.m */; }; + F9E5D4E11D76CF16009F107B /* Manager.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4C11D76CF16009F107B /* Manager.m */; }; + F9E5D4E21D76CF16009F107B /* Request.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4C31D76CF16009F107B /* Request.m */; }; + F9E5D4E31D76CF16009F107B /* BakeChickenWingCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4C61D76CF16009F107B /* BakeChickenWingCommand.m */; }; + F9E5D4E41D76CF16009F107B /* BakeMuttonCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4C81D76CF16009F107B /* BakeMuttonCommand.m */; }; + F9E5D4E51D76CF16009F107B /* Barbecuer.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4CA1D76CF16009F107B /* Barbecuer.m */; }; + F9E5D4E61D76CF16009F107B /* Waiter.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4CD1D76CF16009F107B /* Waiter.m */; }; + F9E5D4E71D76CF16009F107B /* Component.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4D01D76CF16009F107B /* Component.m */; }; + F9E5D4E81D76CF16009F107B /* Composite.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4D21D76CF16009F107B /* Composite.m */; }; + F9E5D4E91D76CF16009F107B /* Leaf.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4D41D76CF16009F107B /* Leaf.m */; }; + F9E5D4EA1D76CF16009F107B /* BigTrouser.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4D71D76CF16009F107B /* BigTrouser.m */; }; + F9E5D4EB1D76CF16009F107B /* Finery.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4D91D76CF16009F107B /* Finery.m */; }; + F9E5D4EC1D76CF16009F107B /* Person.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4DB1D76CF16009F107B /* Person.m */; }; + F9E5D4ED1D76CF16009F107B /* TShirts.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4DD1D76CF16009F107B /* TShirts.m */; }; + F9E5D4F61D76CF24009F107B /* ConcerteWebSite.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4F01D76CF24009F107B /* ConcerteWebSite.m */; }; + F9E5D4F71D76CF24009F107B /* FlyweightUser.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4F21D76CF24009F107B /* FlyweightUser.m */; }; + F9E5D4F81D76CF24009F107B /* WebSiteFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D4F51D76CF24009F107B /* WebSiteFactory.m */; }; + F9E5D55B1D76CF72009F107B /* Expression.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5341D76CF72009F107B /* Expression.m */; }; + F9E5D55C1D76CF72009F107B /* Note.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5361D76CF72009F107B /* Note.m */; }; + F9E5D55D1D76CF72009F107B /* PlayContext.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5381D76CF72009F107B /* PlayContext.m */; }; + F9E5D55E1D76CF72009F107B /* Scale.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D53A1D76CF72009F107B /* Scale.m */; }; + F9E5D55F1D76CF72009F107B /* ConcreteAggregate.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D53E1D76CF72009F107B /* ConcreteAggregate.m */; }; + F9E5D5601D76CF72009F107B /* ConcreteIterator.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5401D76CF72009F107B /* ConcreteIterator.m */; }; + F9E5D5611D76CF72009F107B /* Country.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5441D76CF72009F107B /* Country.m */; }; + F9E5D5621D76CF72009F107B /* Iraq.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5461D76CF72009F107B /* Iraq.m */; }; + F9E5D5631D76CF72009F107B /* UnitedNationsSecurityCouncil.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5491D76CF72009F107B /* UnitedNationsSecurityCouncil.m */; }; + F9E5D5641D76CF72009F107B /* USA.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D54B1D76CF72009F107B /* USA.m */; }; + F9E5D5651D76CF72009F107B /* GameRole.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D54E1D76CF72009F107B /* GameRole.m */; }; + F9E5D5661D76CF72009F107B /* RoleStateCaretaker.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5501D76CF72009F107B /* RoleStateCaretaker.m */; }; + F9E5D5671D76CF72009F107B /* RoleStateMemento.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5521D76CF72009F107B /* RoleStateMemento.m */; }; + F9E5D5681D76CF72009F107B /* ConcreteObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5551D76CF72009F107B /* ConcreteObserver.m */; }; + F9E5D5691D76CF72009F107B /* ConcreteSubject.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5571D76CF72009F107B /* ConcreteSubject.m */; }; + F9E5D56A1D76CF72009F107B /* Subject.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D55A1D76CF72009F107B /* Subject.m */; }; + F9E5D57A1D76CF84009F107B /* Amativeness.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D56E1D76CF84009F107B /* Amativeness.m */; }; + F9E5D57B1D76CF84009F107B /* Failing.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5701D76CF84009F107B /* Failing.m */; }; + F9E5D57C1D76CF84009F107B /* Man.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5721D76CF84009F107B /* Man.m */; }; + F9E5D57D1D76CF84009F107B /* ObjectStructure.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5741D76CF84009F107B /* ObjectStructure.m */; }; + F9E5D57E1D76CF84009F107B /* Success.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5761D76CF84009F107B /* Success.m */; }; + F9E5D57F1D76CF84009F107B /* Woman.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5791D76CF84009F107B /* Woman.m */; }; + F9E5D5821D76CFB2009F107B /* Adapter.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5811D76CFB2009F107B /* Adapter.m */; }; + F9E5D58B1D76CFC2009F107B /* ChainOfResponsibility.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5841D76CFC2009F107B /* ChainOfResponsibility.m */; }; + F9E5D58C1D76CFC2009F107B /* Command.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5861D76CFC2009F107B /* Command.m */; }; + F9E5D58D1D76CFC2009F107B /* CompositeTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5881D76CFC2009F107B /* CompositeTest.m */; }; + F9E5D58E1D76CFC2009F107B /* Decorator.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D58A1D76CFC2009F107B /* Decorator.m */; }; + F9E5D5AD1D76D06C009F107B /* Flyweight.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5A21D76D06C009F107B /* Flyweight.m */; }; + F9E5D5AE1D76D06C009F107B /* Interpreter.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5A41D76D06C009F107B /* Interpreter.m */; }; + F9E5D5AF1D76D06C009F107B /* Iterator.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5A61D76D06C009F107B /* Iterator.m */; }; + F9E5D5B01D76D06C009F107B /* Mediator.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5A81D76D06C009F107B /* Mediator.m */; }; + F9E5D5B11D76D06C009F107B /* Memento.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5AA1D76D06C009F107B /* Memento.m */; }; + F9E5D5B21D76D06C009F107B /* Observe.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5AC1D76D06C009F107B /* Observe.m */; }; + F9E5D5B51D76D0B8009F107B /* Visitor.m in Sources */ = {isa = PBXBuildFile; fileRef = F9E5D5B41D76D0B8009F107B /* Visitor.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -242,6 +301,120 @@ 24B2B0831A067DB1001D74E0 /* BuilderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BuilderTests.m; sourceTree = ""; }; 24BD69891A4477170007D525 /* PrototypeTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PrototypeTests.m; sourceTree = ""; }; 24D9588319FE99B800C3F23E /* StateTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StateTests.m; sourceTree = ""; }; + F9E5D4A71D76CF04009F107B /* Center.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Center.h; sourceTree = ""; }; + F9E5D4A81D76CF04009F107B /* Center.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Center.m; sourceTree = ""; }; + F9E5D4A91D76CF04009F107B /* ForeignCenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForeignCenter.h; sourceTree = ""; }; + F9E5D4AA1D76CF04009F107B /* ForeignCenter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ForeignCenter.m; sourceTree = ""; }; + F9E5D4AB1D76CF04009F107B /* Forwards.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Forwards.h; sourceTree = ""; }; + F9E5D4AC1D76CF04009F107B /* Forwards.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Forwards.m; sourceTree = ""; }; + F9E5D4AD1D76CF04009F107B /* Guards.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Guards.h; sourceTree = ""; }; + F9E5D4AE1D76CF04009F107B /* Guards.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Guards.m; sourceTree = ""; }; + F9E5D4AF1D76CF04009F107B /* Player.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Player.h; sourceTree = ""; }; + F9E5D4B01D76CF04009F107B /* Player.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Player.m; sourceTree = ""; }; + F9E5D4B11D76CF04009F107B /* Translator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Translator.h; sourceTree = ""; }; + F9E5D4B21D76CF04009F107B /* Translator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Translator.m; sourceTree = ""; }; + F9E5D4BA1D76CF16009F107B /* CommonManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonManager.h; sourceTree = ""; }; + F9E5D4BB1D76CF16009F107B /* CommonManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommonManager.m; sourceTree = ""; }; + F9E5D4BC1D76CF16009F107B /* GeneralManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeneralManager.h; sourceTree = ""; }; + F9E5D4BD1D76CF16009F107B /* GeneralManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneralManager.m; sourceTree = ""; }; + F9E5D4BE1D76CF16009F107B /* Majordomo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Majordomo.h; sourceTree = ""; }; + F9E5D4BF1D76CF16009F107B /* Majordomo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Majordomo.m; sourceTree = ""; }; + F9E5D4C01D76CF16009F107B /* Manager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Manager.h; sourceTree = ""; }; + F9E5D4C11D76CF16009F107B /* Manager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Manager.m; sourceTree = ""; }; + F9E5D4C21D76CF16009F107B /* Request.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Request.h; sourceTree = ""; }; + F9E5D4C31D76CF16009F107B /* Request.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Request.m; sourceTree = ""; }; + F9E5D4C51D76CF16009F107B /* BakeChickenWingCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BakeChickenWingCommand.h; sourceTree = ""; }; + F9E5D4C61D76CF16009F107B /* BakeChickenWingCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BakeChickenWingCommand.m; sourceTree = ""; }; + F9E5D4C71D76CF16009F107B /* BakeMuttonCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BakeMuttonCommand.h; sourceTree = ""; }; + F9E5D4C81D76CF16009F107B /* BakeMuttonCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BakeMuttonCommand.m; sourceTree = ""; }; + F9E5D4C91D76CF16009F107B /* Barbecuer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Barbecuer.h; sourceTree = ""; }; + F9E5D4CA1D76CF16009F107B /* Barbecuer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Barbecuer.m; sourceTree = ""; }; + F9E5D4CB1D76CF16009F107B /* Command.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Command.h; sourceTree = ""; }; + F9E5D4CC1D76CF16009F107B /* Waiter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Waiter.h; sourceTree = ""; }; + F9E5D4CD1D76CF16009F107B /* Waiter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Waiter.m; sourceTree = ""; }; + F9E5D4CF1D76CF16009F107B /* Component.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Component.h; sourceTree = ""; }; + F9E5D4D01D76CF16009F107B /* Component.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Component.m; sourceTree = ""; }; + F9E5D4D11D76CF16009F107B /* Composite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Composite.h; sourceTree = ""; }; + F9E5D4D21D76CF16009F107B /* Composite.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Composite.m; sourceTree = ""; }; + F9E5D4D31D76CF16009F107B /* Leaf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Leaf.h; sourceTree = ""; }; + F9E5D4D41D76CF16009F107B /* Leaf.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Leaf.m; sourceTree = ""; }; + F9E5D4D61D76CF16009F107B /* BigTrouser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BigTrouser.h; sourceTree = ""; }; + F9E5D4D71D76CF16009F107B /* BigTrouser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BigTrouser.m; sourceTree = ""; }; + F9E5D4D81D76CF16009F107B /* Finery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Finery.h; sourceTree = ""; }; + F9E5D4D91D76CF16009F107B /* Finery.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Finery.m; sourceTree = ""; }; + F9E5D4DA1D76CF16009F107B /* Person.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Person.h; sourceTree = ""; }; + F9E5D4DB1D76CF16009F107B /* Person.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Person.m; sourceTree = ""; }; + F9E5D4DC1D76CF16009F107B /* TShirts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TShirts.h; sourceTree = ""; }; + F9E5D4DD1D76CF16009F107B /* TShirts.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TShirts.m; sourceTree = ""; }; + F9E5D4EF1D76CF24009F107B /* ConcerteWebSite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConcerteWebSite.h; sourceTree = ""; }; + F9E5D4F01D76CF24009F107B /* ConcerteWebSite.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ConcerteWebSite.m; sourceTree = ""; }; + F9E5D4F11D76CF24009F107B /* FlyweightUser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlyweightUser.h; sourceTree = ""; }; + F9E5D4F21D76CF24009F107B /* FlyweightUser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FlyweightUser.m; sourceTree = ""; }; + F9E5D4F31D76CF24009F107B /* WebSite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSite.h; sourceTree = ""; }; + F9E5D4F41D76CF24009F107B /* WebSiteFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSiteFactory.h; sourceTree = ""; }; + F9E5D4F51D76CF24009F107B /* WebSiteFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebSiteFactory.m; sourceTree = ""; }; + F9E5D5331D76CF72009F107B /* Expression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Expression.h; sourceTree = ""; }; + F9E5D5341D76CF72009F107B /* Expression.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Expression.m; sourceTree = ""; }; + F9E5D5351D76CF72009F107B /* Note.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Note.h; sourceTree = ""; }; + F9E5D5361D76CF72009F107B /* Note.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Note.m; sourceTree = ""; }; + F9E5D5371D76CF72009F107B /* PlayContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlayContext.h; sourceTree = ""; }; + F9E5D5381D76CF72009F107B /* PlayContext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlayContext.m; sourceTree = ""; }; + F9E5D5391D76CF72009F107B /* Scale.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Scale.h; sourceTree = ""; }; + F9E5D53A1D76CF72009F107B /* Scale.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Scale.m; sourceTree = ""; }; + F9E5D53C1D76CF72009F107B /* Aggregate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Aggregate.h; sourceTree = ""; }; + F9E5D53D1D76CF72009F107B /* ConcreteAggregate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConcreteAggregate.h; sourceTree = ""; }; + F9E5D53E1D76CF72009F107B /* ConcreteAggregate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ConcreteAggregate.m; sourceTree = ""; }; + F9E5D53F1D76CF72009F107B /* ConcreteIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConcreteIterator.h; sourceTree = ""; }; + F9E5D5401D76CF72009F107B /* ConcreteIterator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ConcreteIterator.m; sourceTree = ""; }; + F9E5D5411D76CF72009F107B /* Iterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Iterator.h; sourceTree = ""; }; + F9E5D5431D76CF72009F107B /* Country.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Country.h; sourceTree = ""; }; + F9E5D5441D76CF72009F107B /* Country.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Country.m; sourceTree = ""; }; + F9E5D5451D76CF72009F107B /* Iraq.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Iraq.h; sourceTree = ""; }; + F9E5D5461D76CF72009F107B /* Iraq.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Iraq.m; sourceTree = ""; }; + F9E5D5471D76CF72009F107B /* UnitedNations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnitedNations.h; sourceTree = ""; }; + F9E5D5481D76CF72009F107B /* UnitedNationsSecurityCouncil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnitedNationsSecurityCouncil.h; sourceTree = ""; }; + F9E5D5491D76CF72009F107B /* UnitedNationsSecurityCouncil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UnitedNationsSecurityCouncil.m; sourceTree = ""; }; + F9E5D54A1D76CF72009F107B /* USA.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = USA.h; sourceTree = ""; }; + F9E5D54B1D76CF72009F107B /* USA.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = USA.m; sourceTree = ""; }; + F9E5D54D1D76CF72009F107B /* GameRole.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameRole.h; sourceTree = ""; }; + F9E5D54E1D76CF72009F107B /* GameRole.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameRole.m; sourceTree = ""; }; + F9E5D54F1D76CF72009F107B /* RoleStateCaretaker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoleStateCaretaker.h; sourceTree = ""; }; + F9E5D5501D76CF72009F107B /* RoleStateCaretaker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoleStateCaretaker.m; sourceTree = ""; }; + F9E5D5511D76CF72009F107B /* RoleStateMemento.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoleStateMemento.h; sourceTree = ""; }; + F9E5D5521D76CF72009F107B /* RoleStateMemento.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoleStateMemento.m; sourceTree = ""; }; + F9E5D5541D76CF72009F107B /* ConcreteObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConcreteObserver.h; sourceTree = ""; }; + F9E5D5551D76CF72009F107B /* ConcreteObserver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ConcreteObserver.m; sourceTree = ""; }; + F9E5D5561D76CF72009F107B /* ConcreteSubject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConcreteSubject.h; sourceTree = ""; }; + F9E5D5571D76CF72009F107B /* ConcreteSubject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ConcreteSubject.m; sourceTree = ""; }; + F9E5D5581D76CF72009F107B /* Observe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Observe.h; sourceTree = ""; }; + F9E5D5591D76CF72009F107B /* Subject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Subject.h; sourceTree = ""; }; + F9E5D55A1D76CF72009F107B /* Subject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Subject.m; sourceTree = ""; }; + F9E5D56C1D76CF84009F107B /* Action.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Action.h; sourceTree = ""; }; + F9E5D56D1D76CF84009F107B /* Amativeness.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Amativeness.h; sourceTree = ""; }; + F9E5D56E1D76CF84009F107B /* Amativeness.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Amativeness.m; sourceTree = ""; }; + F9E5D56F1D76CF84009F107B /* Failing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Failing.h; sourceTree = ""; }; + F9E5D5701D76CF84009F107B /* Failing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Failing.m; sourceTree = ""; }; + F9E5D5711D76CF84009F107B /* Man.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Man.h; sourceTree = ""; }; + F9E5D5721D76CF84009F107B /* Man.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Man.m; sourceTree = ""; }; + F9E5D5731D76CF84009F107B /* ObjectStructure.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectStructure.h; sourceTree = ""; }; + F9E5D5741D76CF84009F107B /* ObjectStructure.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjectStructure.m; sourceTree = ""; }; + F9E5D5751D76CF84009F107B /* Success.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Success.h; sourceTree = ""; }; + F9E5D5761D76CF84009F107B /* Success.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Success.m; sourceTree = ""; }; + F9E5D5771D76CF84009F107B /* VisitorPerson.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VisitorPerson.h; sourceTree = ""; }; + F9E5D5781D76CF84009F107B /* Woman.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Woman.h; sourceTree = ""; }; + F9E5D5791D76CF84009F107B /* Woman.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Woman.m; sourceTree = ""; }; + F9E5D5811D76CFB2009F107B /* Adapter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Adapter.m; sourceTree = ""; }; + F9E5D5841D76CFC2009F107B /* ChainOfResponsibility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChainOfResponsibility.m; sourceTree = ""; }; + F9E5D5861D76CFC2009F107B /* Command.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Command.m; sourceTree = ""; }; + F9E5D5881D76CFC2009F107B /* CompositeTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CompositeTest.m; sourceTree = ""; }; + F9E5D58A1D76CFC2009F107B /* Decorator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Decorator.m; sourceTree = ""; }; + F9E5D5A21D76D06C009F107B /* Flyweight.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Flyweight.m; sourceTree = ""; }; + F9E5D5A41D76D06C009F107B /* Interpreter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Interpreter.m; sourceTree = ""; }; + F9E5D5A61D76D06C009F107B /* Iterator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Iterator.m; sourceTree = ""; }; + F9E5D5A81D76D06C009F107B /* Mediator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Mediator.m; sourceTree = ""; }; + F9E5D5AA1D76D06C009F107B /* Memento.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Memento.m; sourceTree = ""; }; + F9E5D5AC1D76D06C009F107B /* Observe.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Observe.m; sourceTree = ""; }; + F9E5D5B41D76D0B8009F107B /* Visitor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Visitor.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -536,10 +709,21 @@ isa = PBXGroup; children = ( 245CB3CA1BF8A28C0006D277 /* AbstractFactory */, + F9E5D4A61D76CF04009F107B /* Adapter适配器 */, 245CB3DF1BF8A28C0006D277 /* Bridge */, 245CB3EB1BF8A28C0006D277 /* Builder */, + F9E5D4B91D76CF16009F107B /* ChainOfResponsibility */, + F9E5D4C41D76CF16009F107B /* Command */, + F9E5D4CE1D76CF16009F107B /* Composite组合 */, + F9E5D4D51D76CF16009F107B /* Decorator装饰 */, 245CB3F31BF8A28C0006D277 /* Facade */, 245CB4001BF8A28C0006D277 /* FactoryMethod */, + F9E5D4EE1D76CF24009F107B /* Flyweight */, + F9E5D5321D76CF72009F107B /* Interpreter解释器 */, + F9E5D53B1D76CF72009F107B /* Iterator迭代器 */, + F9E5D5421D76CF72009F107B /* Mediator中介者 */, + F9E5D54C1D76CF72009F107B /* Memento备忘录 */, + F9E5D5531D76CF72009F107B /* Observe观察者 */, 245CB40B1BF8A28C0006D277 /* Prototype */, 245CB4141BF8A28C0006D277 /* Proxy */, 245CB41C1BF8A28C0006D277 /* SimpleFactory */, @@ -547,6 +731,7 @@ 245CB42C1BF8A28C0006D277 /* State */, 245CB43C1BF8A28C0006D277 /* Strategy */, 245CB4461BF8A28C0006D277 /* TemplateMethod */, + F9E5D56B1D76CF84009F107B /* Visitor访问者 */, 2467F51A19F37ED800437073 /* AppDelegate.h */, 2467F51B19F37ED800437073 /* AppDelegate.m */, 2467F51D19F37ED800437073 /* Images.xcassets */, @@ -569,19 +754,31 @@ 2467F52A19F37ED900437073 /* DesignPatternsTests */ = { isa = PBXGroup; children = ( + 2407155519F3EB9100E9F749 /* AbstractFactory */, + F9E5D5801D76CFB2009F107B /* Adapter适配器 */, + 24B2B0651A066AF1001D74E0 /* Bridge */, + 24B2B0821A067DA0001D74E0 /* Builder */, + F9E5D5831D76CFC2009F107B /* ChainOfResponsibility */, + F9E5D5851D76CFC2009F107B /* Command命令 */, + F9E5D5871D76CFC2009F107B /* Composite组合 */, + F9E5D5891D76CFC2009F107B /* Decorator装饰 */, + 24926FD31A432717006E188B /* Facade */, + 2467F55D19F3A1E200437073 /* FactoryMethod */, + F9E5D5A11D76D06C009F107B /* Flyweight */, + F9E5D5A31D76D06C009F107B /* Interpreter解释器 */, + F9E5D5A51D76D06C009F107B /* Iterator迭代器 */, + F9E5D5A71D76D06C009F107B /* Mediator中介者 */, + F9E5D5A91D76D06C009F107B /* Memento备忘录 */, + F9E5D5AB1D76D06C009F107B /* Observe观察者 */, 24BD69861A44762C0007D525 /* Prototype */, 2406AAEF1A433A7D00B2A359 /* Proxy */, - 24926FD31A432717006E188B /* Facade */, + 2467F54B19F3813100437073 /* SimpleFactory */, 2437B0451A089ABA007CE0EF /* Singleton */, - 24B2B0821A067DA0001D74E0 /* Builder */, - 24B2B0651A066AF1001D74E0 /* Bridge */, - 24B2B04E1A060A0C001D74E0 /* TemplateMethod */, 24D9588219FE99A900C3F23E /* State */, 2491E15D19F7F074009AC42F /* Strategy */, - 2407155519F3EB9100E9F749 /* AbstractFactory */, - 2467F55D19F3A1E200437073 /* FactoryMethod */, - 2467F54B19F3813100437073 /* SimpleFactory */, 2467F52B19F37ED900437073 /* Supporting Files */, + 24B2B04E1A060A0C001D74E0 /* TemplateMethod */, + F9E5D5B31D76D0B8009F107B /* Visitor访问者 */, ); path = DesignPatternsTests; sourceTree = ""; @@ -667,6 +864,288 @@ path = State; sourceTree = ""; }; + F9E5D4A61D76CF04009F107B /* Adapter适配器 */ = { + isa = PBXGroup; + children = ( + F9E5D4A71D76CF04009F107B /* Center.h */, + F9E5D4A81D76CF04009F107B /* Center.m */, + F9E5D4A91D76CF04009F107B /* ForeignCenter.h */, + F9E5D4AA1D76CF04009F107B /* ForeignCenter.m */, + F9E5D4AB1D76CF04009F107B /* Forwards.h */, + F9E5D4AC1D76CF04009F107B /* Forwards.m */, + F9E5D4AD1D76CF04009F107B /* Guards.h */, + F9E5D4AE1D76CF04009F107B /* Guards.m */, + F9E5D4AF1D76CF04009F107B /* Player.h */, + F9E5D4B01D76CF04009F107B /* Player.m */, + F9E5D4B11D76CF04009F107B /* Translator.h */, + F9E5D4B21D76CF04009F107B /* Translator.m */, + ); + path = "Adapter适配器"; + sourceTree = ""; + }; + F9E5D4B91D76CF16009F107B /* ChainOfResponsibility */ = { + isa = PBXGroup; + children = ( + F9E5D4BA1D76CF16009F107B /* CommonManager.h */, + F9E5D4BB1D76CF16009F107B /* CommonManager.m */, + F9E5D4BC1D76CF16009F107B /* GeneralManager.h */, + F9E5D4BD1D76CF16009F107B /* GeneralManager.m */, + F9E5D4BE1D76CF16009F107B /* Majordomo.h */, + F9E5D4BF1D76CF16009F107B /* Majordomo.m */, + F9E5D4C01D76CF16009F107B /* Manager.h */, + F9E5D4C11D76CF16009F107B /* Manager.m */, + F9E5D4C21D76CF16009F107B /* Request.h */, + F9E5D4C31D76CF16009F107B /* Request.m */, + ); + path = ChainOfResponsibility; + sourceTree = ""; + }; + F9E5D4C41D76CF16009F107B /* Command */ = { + isa = PBXGroup; + children = ( + F9E5D4C51D76CF16009F107B /* BakeChickenWingCommand.h */, + F9E5D4C61D76CF16009F107B /* BakeChickenWingCommand.m */, + F9E5D4C71D76CF16009F107B /* BakeMuttonCommand.h */, + F9E5D4C81D76CF16009F107B /* BakeMuttonCommand.m */, + F9E5D4C91D76CF16009F107B /* Barbecuer.h */, + F9E5D4CA1D76CF16009F107B /* Barbecuer.m */, + F9E5D4CB1D76CF16009F107B /* Command.h */, + F9E5D4CC1D76CF16009F107B /* Waiter.h */, + F9E5D4CD1D76CF16009F107B /* Waiter.m */, + ); + path = Command; + sourceTree = ""; + }; + F9E5D4CE1D76CF16009F107B /* Composite组合 */ = { + isa = PBXGroup; + children = ( + F9E5D4CF1D76CF16009F107B /* Component.h */, + F9E5D4D01D76CF16009F107B /* Component.m */, + F9E5D4D11D76CF16009F107B /* Composite.h */, + F9E5D4D21D76CF16009F107B /* Composite.m */, + F9E5D4D31D76CF16009F107B /* Leaf.h */, + F9E5D4D41D76CF16009F107B /* Leaf.m */, + ); + path = "Composite组合"; + sourceTree = ""; + }; + F9E5D4D51D76CF16009F107B /* Decorator装饰 */ = { + isa = PBXGroup; + children = ( + F9E5D4D61D76CF16009F107B /* BigTrouser.h */, + F9E5D4D71D76CF16009F107B /* BigTrouser.m */, + F9E5D4D81D76CF16009F107B /* Finery.h */, + F9E5D4D91D76CF16009F107B /* Finery.m */, + F9E5D4DA1D76CF16009F107B /* Person.h */, + F9E5D4DB1D76CF16009F107B /* Person.m */, + F9E5D4DC1D76CF16009F107B /* TShirts.h */, + F9E5D4DD1D76CF16009F107B /* TShirts.m */, + ); + path = "Decorator装饰"; + sourceTree = ""; + }; + F9E5D4EE1D76CF24009F107B /* Flyweight */ = { + isa = PBXGroup; + children = ( + F9E5D4EF1D76CF24009F107B /* ConcerteWebSite.h */, + F9E5D4F01D76CF24009F107B /* ConcerteWebSite.m */, + F9E5D4F11D76CF24009F107B /* FlyweightUser.h */, + F9E5D4F21D76CF24009F107B /* FlyweightUser.m */, + F9E5D4F31D76CF24009F107B /* WebSite.h */, + F9E5D4F41D76CF24009F107B /* WebSiteFactory.h */, + F9E5D4F51D76CF24009F107B /* WebSiteFactory.m */, + ); + path = Flyweight; + sourceTree = ""; + }; + F9E5D5321D76CF72009F107B /* Interpreter解释器 */ = { + isa = PBXGroup; + children = ( + F9E5D5331D76CF72009F107B /* Expression.h */, + F9E5D5341D76CF72009F107B /* Expression.m */, + F9E5D5351D76CF72009F107B /* Note.h */, + F9E5D5361D76CF72009F107B /* Note.m */, + F9E5D5371D76CF72009F107B /* PlayContext.h */, + F9E5D5381D76CF72009F107B /* PlayContext.m */, + F9E5D5391D76CF72009F107B /* Scale.h */, + F9E5D53A1D76CF72009F107B /* Scale.m */, + ); + path = "Interpreter解释器"; + sourceTree = ""; + }; + F9E5D53B1D76CF72009F107B /* Iterator迭代器 */ = { + isa = PBXGroup; + children = ( + F9E5D53C1D76CF72009F107B /* Aggregate.h */, + F9E5D53D1D76CF72009F107B /* ConcreteAggregate.h */, + F9E5D53E1D76CF72009F107B /* ConcreteAggregate.m */, + F9E5D53F1D76CF72009F107B /* ConcreteIterator.h */, + F9E5D5401D76CF72009F107B /* ConcreteIterator.m */, + F9E5D5411D76CF72009F107B /* Iterator.h */, + ); + path = "Iterator迭代器"; + sourceTree = ""; + }; + F9E5D5421D76CF72009F107B /* Mediator中介者 */ = { + isa = PBXGroup; + children = ( + F9E5D5431D76CF72009F107B /* Country.h */, + F9E5D5441D76CF72009F107B /* Country.m */, + F9E5D5451D76CF72009F107B /* Iraq.h */, + F9E5D5461D76CF72009F107B /* Iraq.m */, + F9E5D5471D76CF72009F107B /* UnitedNations.h */, + F9E5D5481D76CF72009F107B /* UnitedNationsSecurityCouncil.h */, + F9E5D5491D76CF72009F107B /* UnitedNationsSecurityCouncil.m */, + F9E5D54A1D76CF72009F107B /* USA.h */, + F9E5D54B1D76CF72009F107B /* USA.m */, + ); + path = "Mediator中介者"; + sourceTree = ""; + }; + F9E5D54C1D76CF72009F107B /* Memento备忘录 */ = { + isa = PBXGroup; + children = ( + F9E5D54D1D76CF72009F107B /* GameRole.h */, + F9E5D54E1D76CF72009F107B /* GameRole.m */, + F9E5D54F1D76CF72009F107B /* RoleStateCaretaker.h */, + F9E5D5501D76CF72009F107B /* RoleStateCaretaker.m */, + F9E5D5511D76CF72009F107B /* RoleStateMemento.h */, + F9E5D5521D76CF72009F107B /* RoleStateMemento.m */, + ); + path = "Memento备忘录"; + sourceTree = ""; + }; + F9E5D5531D76CF72009F107B /* Observe观察者 */ = { + isa = PBXGroup; + children = ( + F9E5D5541D76CF72009F107B /* ConcreteObserver.h */, + F9E5D5551D76CF72009F107B /* ConcreteObserver.m */, + F9E5D5561D76CF72009F107B /* ConcreteSubject.h */, + F9E5D5571D76CF72009F107B /* ConcreteSubject.m */, + F9E5D5581D76CF72009F107B /* Observe.h */, + F9E5D5591D76CF72009F107B /* Subject.h */, + F9E5D55A1D76CF72009F107B /* Subject.m */, + ); + path = "Observe观察者"; + sourceTree = ""; + }; + F9E5D56B1D76CF84009F107B /* Visitor访问者 */ = { + isa = PBXGroup; + children = ( + F9E5D56C1D76CF84009F107B /* Action.h */, + F9E5D56D1D76CF84009F107B /* Amativeness.h */, + F9E5D56E1D76CF84009F107B /* Amativeness.m */, + F9E5D56F1D76CF84009F107B /* Failing.h */, + F9E5D5701D76CF84009F107B /* Failing.m */, + F9E5D5711D76CF84009F107B /* Man.h */, + F9E5D5721D76CF84009F107B /* Man.m */, + F9E5D5731D76CF84009F107B /* ObjectStructure.h */, + F9E5D5741D76CF84009F107B /* ObjectStructure.m */, + F9E5D5751D76CF84009F107B /* Success.h */, + F9E5D5761D76CF84009F107B /* Success.m */, + F9E5D5771D76CF84009F107B /* VisitorPerson.h */, + F9E5D5781D76CF84009F107B /* Woman.h */, + F9E5D5791D76CF84009F107B /* Woman.m */, + ); + path = "Visitor访问者"; + sourceTree = ""; + }; + F9E5D5801D76CFB2009F107B /* Adapter适配器 */ = { + isa = PBXGroup; + children = ( + F9E5D5811D76CFB2009F107B /* Adapter.m */, + ); + path = "Adapter适配器"; + sourceTree = ""; + }; + F9E5D5831D76CFC2009F107B /* ChainOfResponsibility */ = { + isa = PBXGroup; + children = ( + F9E5D5841D76CFC2009F107B /* ChainOfResponsibility.m */, + ); + path = ChainOfResponsibility; + sourceTree = ""; + }; + F9E5D5851D76CFC2009F107B /* Command命令 */ = { + isa = PBXGroup; + children = ( + F9E5D5861D76CFC2009F107B /* Command.m */, + ); + path = "Command命令"; + sourceTree = ""; + }; + F9E5D5871D76CFC2009F107B /* Composite组合 */ = { + isa = PBXGroup; + children = ( + F9E5D5881D76CFC2009F107B /* CompositeTest.m */, + ); + path = "Composite组合"; + sourceTree = ""; + }; + F9E5D5891D76CFC2009F107B /* Decorator装饰 */ = { + isa = PBXGroup; + children = ( + F9E5D58A1D76CFC2009F107B /* Decorator.m */, + ); + path = "Decorator装饰"; + sourceTree = ""; + }; + F9E5D5A11D76D06C009F107B /* Flyweight */ = { + isa = PBXGroup; + children = ( + F9E5D5A21D76D06C009F107B /* Flyweight.m */, + ); + path = Flyweight; + sourceTree = ""; + }; + F9E5D5A31D76D06C009F107B /* Interpreter解释器 */ = { + isa = PBXGroup; + children = ( + F9E5D5A41D76D06C009F107B /* Interpreter.m */, + ); + path = "Interpreter解释器"; + sourceTree = ""; + }; + F9E5D5A51D76D06C009F107B /* Iterator迭代器 */ = { + isa = PBXGroup; + children = ( + F9E5D5A61D76D06C009F107B /* Iterator.m */, + ); + path = "Iterator迭代器"; + sourceTree = ""; + }; + F9E5D5A71D76D06C009F107B /* Mediator中介者 */ = { + isa = PBXGroup; + children = ( + F9E5D5A81D76D06C009F107B /* Mediator.m */, + ); + path = "Mediator中介者"; + sourceTree = ""; + }; + F9E5D5A91D76D06C009F107B /* Memento备忘录 */ = { + isa = PBXGroup; + children = ( + F9E5D5AA1D76D06C009F107B /* Memento.m */, + ); + path = "Memento备忘录"; + sourceTree = ""; + }; + F9E5D5AB1D76D06C009F107B /* Observe观察者 */ = { + isa = PBXGroup; + children = ( + F9E5D5AC1D76D06C009F107B /* Observe.m */, + ); + path = "Observe观察者"; + sourceTree = ""; + }; + F9E5D5B31D76D0B8009F107B /* Visitor访问者 */ = { + isa = PBXGroup; + children = ( + F9E5D5B41D76D0B8009F107B /* Visitor.m */, + ); + path = "Visitor访问者"; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -763,62 +1242,109 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + F9E5D4EB1D76CF16009F107B /* Finery.m in Sources */, 245CB4551BF8A28C0006D277 /* HandsetAddressList.m in Sources */, + F9E5D4EC1D76CF16009F107B /* Person.m in Sources */, 245CB4681BF8A28C0006D277 /* ResumeDeepCopy.m in Sources */, + F9E5D55F1D76CF72009F107B /* ConcreteAggregate.m in Sources */, 245CB4801BF8A28C0006D277 /* TestPaper.m in Sources */, 245CB47A1BF8A28C0006D277 /* SleepingState.m in Sources */, 245CB44E1BF8A28C0006D277 /* AccessFactory.m in Sources */, + F9E5D5611D76CF72009F107B /* Country.m in Sources */, + F9E5D5661D76CF72009F107B /* RoleStateCaretaker.m in Sources */, 245CB46E1BF8A28C0006D277 /* Operation.m in Sources */, + F9E5D4B51D76CF04009F107B /* Forwards.m in Sources */, 245CB47E1BF8A28C0006D277 /* CashRebate.m in Sources */, + F9E5D4E81D76CF16009F107B /* Composite.m in Sources */, + F9E5D55D1D76CF72009F107B /* PlayContext.m in Sources */, + F9E5D5691D76CF72009F107B /* ConcreteSubject.m in Sources */, + F9E5D57D1D76CF84009F107B /* ObjectStructure.m in Sources */, 245CB4641BF8A28C0006D277 /* UndergraduateFactory.m in Sources */, + F9E5D4E71D76CF16009F107B /* Component.m in Sources */, 245CB4611BF8A28C0006D277 /* Stock2.m in Sources */, 245CB4791BF8A28C0006D277 /* RestState.m in Sources */, + F9E5D4B81D76CF04009F107B /* Translator.m in Sources */, 245CB4631BF8A28C0006D277 /* Undergraduate.m in Sources */, 245CB46B1BF8A28C0006D277 /* Proxy.m in Sources */, 245CB47C1BF8A28C0006D277 /* CashContext.m in Sources */, + F9E5D4ED1D76CF16009F107B /* TShirts.m in Sources */, + F9E5D4F61D76CF24009F107B /* ConcerteWebSite.m in Sources */, + F9E5D4F81D76CF24009F107B /* WebSiteFactory.m in Sources */, + F9E5D5631D76CF72009F107B /* UnitedNationsSecurityCouncil.m in Sources */, + F9E5D4E01D76CF16009F107B /* Majordomo.m in Sources */, + F9E5D55E1D76CF72009F107B /* Scale.m in Sources */, 245CB4661BF8A28C0006D277 /* VolunteerFactory.m in Sources */, 245CB47D1BF8A28C0006D277 /* CashNormal.m in Sources */, + F9E5D55C1D76CF72009F107B /* Note.m in Sources */, 245CB4691BF8A28C0006D277 /* ResumeShallowCopy.m in Sources */, 245CB4581BF8A28C0006D277 /* HandsetBrandN.m in Sources */, 245CB4821BF8A28C0006D277 /* TestPaperB.m in Sources */, 245CB45C1BF8A28C0006D277 /* PersonThinBuilder.m in Sources */, + F9E5D57B1D76CF84009F107B /* Failing.m in Sources */, 245CB4811BF8A28C0006D277 /* TestPaperA.m in Sources */, + F9E5D4E51D76CF16009F107B /* Barbecuer.m in Sources */, 245CB45E1BF8A28C0006D277 /* NationalDebt1.m in Sources */, 245CB4511BF8A28C0006D277 /* User.m in Sources */, + F9E5D4EA1D76CF16009F107B /* BigTrouser.m in Sources */, + F9E5D4E21D76CF16009F107B /* Request.m in Sources */, + F9E5D4B71D76CF04009F107B /* Player.m in Sources */, 245CB4561BF8A28C0006D277 /* HandsetBrand.m in Sources */, + F9E5D57E1D76CF84009F107B /* Success.m in Sources */, 2467F51C19F37ED800437073 /* AppDelegate.m in Sources */, 245CB46F1BF8A28C0006D277 /* OperationAdd.m in Sources */, 245CB4671BF8A28C0006D277 /* Resume.m in Sources */, 245CB4521BF8A28C0006D277 /* SQLServerDepartment.m in Sources */, + F9E5D4E11D76CF16009F107B /* Manager.m in Sources */, 245CB4621BF8A28C0006D277 /* Stock3.m in Sources */, + F9E5D57C1D76CF84009F107B /* Man.m in Sources */, + F9E5D4B31D76CF04009F107B /* Center.m in Sources */, + F9E5D57A1D76CF84009F107B /* Amativeness.m in Sources */, 245CB4771BF8A28C0006D277 /* ForenoonState.m in Sources */, 245CB4541BF8A28C0006D277 /* SQLServerUser.m in Sources */, 245CB4651BF8A28C0006D277 /* Volunteer.m in Sources */, 245CB4781BF8A28C0006D277 /* NoonState.m in Sources */, + F9E5D4DF1D76CF16009F107B /* GeneralManager.m in Sources */, 245CB4591BF8A28C0006D277 /* HandsetGame.m in Sources */, 245CB47B1BF8A28C0006D277 /* Work.m in Sources */, 245CB4701BF8A28C0006D277 /* OperationDiv.m in Sources */, + F9E5D5641D76CF72009F107B /* USA.m in Sources */, 245CB4721BF8A28C0006D277 /* OperationMul.m in Sources */, + F9E5D4E41D76CF16009F107B /* BakeMuttonCommand.m in Sources */, 245CB4731BF8A28C0006D277 /* OperationSub.m in Sources */, + F9E5D4E91D76CF16009F107B /* Leaf.m in Sources */, 2467F51819F37ED800437073 /* main.m in Sources */, + F9E5D4B41D76CF04009F107B /* ForeignCenter.m in Sources */, + F9E5D4E31D76CF16009F107B /* BakeChickenWingCommand.m in Sources */, + F9E5D4B61D76CF04009F107B /* Guards.m in Sources */, + F9E5D5621D76CF72009F107B /* Iraq.m in Sources */, 245CB44D1BF8A28C0006D277 /* AccessDepartment.m in Sources */, + F9E5D56A1D76CF72009F107B /* Subject.m in Sources */, + F9E5D4F71D76CF24009F107B /* FlyweightUser.m in Sources */, 245CB46A1BF8A28C0006D277 /* WorkExperience.m in Sources */, + F9E5D4E61D76CF16009F107B /* Waiter.m in Sources */, 245CB46C1BF8A28C0006D277 /* Pursuit.m in Sources */, 245CB45B1BF8A28C0006D277 /* PersonFatBuilder.m in Sources */, + F9E5D5601D76CF72009F107B /* ConcreteIterator.m in Sources */, 245CB4601BF8A28C0006D277 /* Stock1.m in Sources */, 245CB4531BF8A28C0006D277 /* SQLServerFactory.m in Sources */, 245CB44F1BF8A28C0006D277 /* AccessUser.m in Sources */, + F9E5D5681D76CF72009F107B /* ConcreteObserver.m in Sources */, + F9E5D55B1D76CF72009F107B /* Expression.m in Sources */, + F9E5D4DE1D76CF16009F107B /* CommonManager.m in Sources */, 245CB4711BF8A28C0006D277 /* OperationFactory.m in Sources */, 245CB46D1BF8A28C0006D277 /* SchoolGirl.m in Sources */, 245CB4501BF8A28C0006D277 /* Department.m in Sources */, 245CB45F1BF8A28C0006D277 /* Realty1.m in Sources */, 245CB45A1BF8A28C0006D277 /* PersonDirector.m in Sources */, + F9E5D57F1D76CF84009F107B /* Woman.m in Sources */, + F9E5D5651D76CF72009F107B /* GameRole.m in Sources */, 245CB4741BF8A28C0006D277 /* Singleton.m in Sources */, 245CB45D1BF8A28C0006D277 /* Fund.m in Sources */, 245CB47F1BF8A28C0006D277 /* CashReturn.m in Sources */, 245CB4751BF8A28C0006D277 /* AfternoonState.m in Sources */, 245CB4761BF8A28C0006D277 /* EveningState.m in Sources */, 245CB4571BF8A28C0006D277 /* HandsetBrandM.m in Sources */, + F9E5D5671D76CF72009F107B /* RoleStateMemento.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -829,15 +1355,27 @@ 24B2B0501A060A28001D74E0 /* TemplateMethodTests.m in Sources */, 2406AAF11A433A8900B2A359 /* ProxyTests.m in Sources */, 2437B04B1A089B0C007CE0EF /* SingletonTests.m in Sources */, + F9E5D5B01D76D06C009F107B /* Mediator.m in Sources */, 24B2B0841A067DB1001D74E0 /* BuilderTests.m in Sources */, + F9E5D58C1D76CFC2009F107B /* Command.m in Sources */, + F9E5D58E1D76CFC2009F107B /* Decorator.m in Sources */, + F9E5D5B11D76D06C009F107B /* Memento.m in Sources */, + F9E5D5821D76CFB2009F107B /* Adapter.m in Sources */, + F9E5D5B21D76D06C009F107B /* Observe.m in Sources */, + F9E5D5AE1D76D06C009F107B /* Interpreter.m in Sources */, 24926FD51A43272A006E188B /* FacadeTests.m in Sources */, + F9E5D58B1D76CFC2009F107B /* ChainOfResponsibility.m in Sources */, 24D9588419FE99B800C3F23E /* StateTests.m in Sources */, 24B2B06D1A066B81001D74E0 /* BridgeTests.m in Sources */, 2407155719F3EBB500E9F749 /* AbstractFactoryTests.m in Sources */, 2467F54D19F3819200437073 /* SimpleFactoryTests.m in Sources */, 2491E15F19F7F0AE009AC42F /* StrategyTests.m in Sources */, + F9E5D5AF1D76D06C009F107B /* Iterator.m in Sources */, + F9E5D58D1D76CFC2009F107B /* CompositeTest.m in Sources */, + F9E5D5B51D76D0B8009F107B /* Visitor.m in Sources */, 24BD698A1A4477170007D525 /* PrototypeTests.m in Sources */, 2467F55F19F3A1F400437073 /* FactoryMethodTests.m in Sources */, + F9E5D5AD1D76D06C009F107B /* Flyweight.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git "a/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Center.h" "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Center.h" new file mode 100644 index 0000000..b469a2c --- /dev/null +++ "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Center.h" @@ -0,0 +1,13 @@ +// +// Center.h +// DesignPatterns +// +// Created by RenPeng on 16/8/24. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Player.h" + +@interface Center : Player + +@end diff --git "a/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Center.m" "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Center.m" new file mode 100644 index 0000000..acfa9ef --- /dev/null +++ "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Center.m" @@ -0,0 +1,32 @@ +// +// Center.m +// DesignPatterns +// +// Created by RenPeng on 16/8/24. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Center.h" + +@interface Center () +@property (nonatomic, copy) NSString *name; +@end + +@implementation Center + +- (instancetype)initWithName:(NSString *)name{ + self = [super initWithName:name]; + if (self) { + self.name = name; + } + return self; +} + +- (void)attack{ + NSLog(@"中锋:%@ 进攻",self.name); +} + +- (void)defense{ + NSLog(@"中锋:%@ 防守",self.name); +} +@end diff --git "a/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/ForeignCenter.h" "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/ForeignCenter.h" new file mode 100644 index 0000000..1b381ac --- /dev/null +++ "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/ForeignCenter.h" @@ -0,0 +1,19 @@ +// +// ForeignCenter.h +// DesignPatterns +// +// Created by RenPeng on 16/8/24. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import + +@interface ForeignCenter : NSObject + +@property (nonatomic, copy) NSString *name; + +- (instancetype)initWithName:(NSString *)name; + +- (void)jingong; +- (void)fangshou; +@end diff --git "a/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/ForeignCenter.m" "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/ForeignCenter.m" new file mode 100644 index 0000000..0a43ac1 --- /dev/null +++ "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/ForeignCenter.m" @@ -0,0 +1,28 @@ +// +// ForeignCenter.m +// DesignPatterns +// +// Created by RenPeng on 16/8/24. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "ForeignCenter.h" + +@implementation ForeignCenter + +- (instancetype)initWithName:(NSString *)name{ + self = [super init]; + if (self) { + self.name = name; + } + return self; +} + +- (void)jingong{ + NSLog(@"外籍中锋:%@ 进攻",self.name); +} + +- (void)fangshou{ + NSLog(@"外籍中锋:%@ 防守",self.name); +} +@end diff --git "a/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Forwards.h" "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Forwards.h" new file mode 100644 index 0000000..764de28 --- /dev/null +++ "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Forwards.h" @@ -0,0 +1,18 @@ +// +// Forwards.h +// DesignPatterns +// +// Created by RenPeng on 16/8/24. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Player.h" + +/** + * 前锋 + */ +@interface Forwards : Player + + + +@end diff --git "a/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Forwards.m" "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Forwards.m" new file mode 100644 index 0000000..f37ff44 --- /dev/null +++ "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Forwards.m" @@ -0,0 +1,32 @@ +// +// Forwards.m +// DesignPatterns +// +// Created by RenPeng on 16/8/24. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Forwards.h" + +@interface Forwards () +@property (nonatomic, copy) NSString *name; +@end + +@implementation Forwards + +- (instancetype)initWithName:(NSString *)name{ + self = [super initWithName:name]; + if (self) { + self.name = name; + } + return self; +} + +- (void)attack{ + NSLog(@"前锋:%@ 进攻",self.name); +} + +- (void)defense{ + NSLog(@"前锋:%@ 防守",self.name); +} +@end diff --git "a/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Guards.h" "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Guards.h" new file mode 100644 index 0000000..8947363 --- /dev/null +++ "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Guards.h" @@ -0,0 +1,13 @@ +// +// Guards.h +// DesignPatterns +// +// Created by RenPeng on 16/8/24. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Player.h" + +@interface Guards : Player + +@end diff --git "a/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Guards.m" "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Guards.m" new file mode 100644 index 0000000..14e5fec --- /dev/null +++ "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Guards.m" @@ -0,0 +1,32 @@ +// +// Guards.m +// DesignPatterns +// +// Created by RenPeng on 16/8/24. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Guards.h" + +@interface Guards () +@property (nonatomic, copy) NSString *name; +@end + +@implementation Guards + +- (instancetype)initWithName:(NSString *)name{ + self = [super initWithName:name]; + if (self) { + self.name = name; + } + return self; +} + +- (void)attack{ + NSLog(@"后卫:%@ 进攻",self.name); +} + +- (void)defense{ + NSLog(@"后卫:%@ 防守",self.name); +} +@end diff --git "a/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Player.h" "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Player.h" new file mode 100644 index 0000000..a46a431 --- /dev/null +++ "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Player.h" @@ -0,0 +1,18 @@ +// +// Player.h +// DesignPatterns +// +// Created by RenPeng on 16/8/24. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import + +@interface Player : NSObject + +- (instancetype)initWithName:(NSString *)name; + +- (void)attack; +- (void)defense; + +@end diff --git "a/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Player.m" "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Player.m" new file mode 100644 index 0000000..d9a29bb --- /dev/null +++ "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Player.m" @@ -0,0 +1,33 @@ +// +// Player.m +// DesignPatterns +// +// Created by RenPeng on 16/8/24. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Player.h" + +@interface Player () +@property (nonatomic, copy) NSString *name; +@end + +@implementation Player + +- (instancetype)initWithName:(NSString *)name{ + self = [super init]; + if (self) { + self.name = name; + } + return self; +} + +- (void)attack{ + +} + +- (void)defense{ + +} + +@end diff --git "a/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Translator.h" "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Translator.h" new file mode 100644 index 0000000..9c73fe8 --- /dev/null +++ "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Translator.h" @@ -0,0 +1,15 @@ +// +// Translator.h +// DesignPatterns +// +// Created by RenPeng on 16/8/24. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Player.h" + +@interface Translator : Player + +- (instancetype)initWithName:(NSString *)name; + +@end diff --git "a/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Translator.m" "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Translator.m" new file mode 100644 index 0000000..41ad0a6 --- /dev/null +++ "b/DesignPatterns/Adapter\351\200\202\351\205\215\345\231\250/Translator.m" @@ -0,0 +1,42 @@ +// +// Translator.m +// DesignPatterns +// +// Created by RenPeng on 16/8/24. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Translator.h" +#import "ForeignCenter.h" + +@interface Translator () +@property (nonatomic, strong) ForeignCenter *wjzf; +@end + +@implementation Translator + +//- (ForeignCenter *)wjzf{ +// if (!_wjzf) { +// _wjzf = [[ForeignCenter alloc] init]; +// } +// return _wjzf; +//} + +- (instancetype)initWithName:(NSString *)name{ + self = [super initWithName:name]; + if (self) { +// self.wjzf.name = name; + self.wjzf = [[ForeignCenter alloc] initWithName:name]; + } + return self; +} + +- (void)attack{ + [self.wjzf jingong]; +} + +- (void)defense{ + [self.wjzf fangshou]; +} + +@end diff --git a/DesignPatterns/ChainOfResponsibility/CommonManager.h b/DesignPatterns/ChainOfResponsibility/CommonManager.h new file mode 100644 index 0000000..1b615b0 --- /dev/null +++ b/DesignPatterns/ChainOfResponsibility/CommonManager.h @@ -0,0 +1,15 @@ +// +// CommonManager.h +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Manager.h" + +@interface CommonManager : Manager + +- (instancetype)initWithName:(NSString *)name; + +@end diff --git a/DesignPatterns/ChainOfResponsibility/CommonManager.m b/DesignPatterns/ChainOfResponsibility/CommonManager.m new file mode 100644 index 0000000..b430f14 --- /dev/null +++ b/DesignPatterns/ChainOfResponsibility/CommonManager.m @@ -0,0 +1,33 @@ +// +// CommonManager.m +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "CommonManager.h" + +@implementation CommonManager + +- (instancetype)initWithName:(NSString *)name{ + self = [super init]; + if (self) { + self.name = name; + } + return self; +} + +//override + +- (void)requestApplications:(Request *)request{ + if (request.type == RequestType_Leave && request.number <= 2) { + NSLog(@"%@:%@,数量%ld被批准",self.name,request.content,(long)request.number); + }else{ + if (self.superior) { + [self.superior requestApplications:request]; + } + } +} + +@end diff --git a/DesignPatterns/ChainOfResponsibility/GeneralManager.h b/DesignPatterns/ChainOfResponsibility/GeneralManager.h new file mode 100644 index 0000000..38cc456 --- /dev/null +++ b/DesignPatterns/ChainOfResponsibility/GeneralManager.h @@ -0,0 +1,14 @@ +// +// GeneralManager.h +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Manager.h" + +@interface GeneralManager : Manager + +- (instancetype)initWithName:(NSString *)name; +@end diff --git a/DesignPatterns/ChainOfResponsibility/GeneralManager.m b/DesignPatterns/ChainOfResponsibility/GeneralManager.m new file mode 100644 index 0000000..c17d513 --- /dev/null +++ b/DesignPatterns/ChainOfResponsibility/GeneralManager.m @@ -0,0 +1,40 @@ +// +// GeneralManager.m +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "GeneralManager.h" + +@implementation GeneralManager + +- (instancetype)initWithName:(NSString *)name{ + self = [super init]; + if (self) { + self.name = name; + } + return self; +} + +//override + +- (void)requestApplications:(Request *)request{ + switch (request.type) { + case RequestType_Leave: + NSLog(@"%@:%@,数量%ld被批准",self.name,request.content,(long)request.number); + break; + case RequestType_SalaryRaise: + if (request.number <= 500) { + NSLog(@"%@:%@,数量%ld被批准",self.name,request.content,(long)request.number); + }else{ + NSLog(@"%@:%@,数量%ld再说吧!",self.name,request.content,(long)request.number); + } + break; + default: + break; + } +} + +@end diff --git a/DesignPatterns/ChainOfResponsibility/Majordomo.h b/DesignPatterns/ChainOfResponsibility/Majordomo.h new file mode 100644 index 0000000..cb4bc6a --- /dev/null +++ b/DesignPatterns/ChainOfResponsibility/Majordomo.h @@ -0,0 +1,14 @@ +// +// Majordomo.h +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Manager.h" + +@interface Majordomo : Manager + +- (instancetype)initWithName:(NSString *)name; +@end diff --git a/DesignPatterns/ChainOfResponsibility/Majordomo.m b/DesignPatterns/ChainOfResponsibility/Majordomo.m new file mode 100644 index 0000000..2d3d656 --- /dev/null +++ b/DesignPatterns/ChainOfResponsibility/Majordomo.m @@ -0,0 +1,32 @@ +// +// Majordomo.m +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Majordomo.h" + +@implementation Majordomo + +- (instancetype)initWithName:(NSString *)name{ + self = [super init]; + if (self) { + self.name = name; + } + return self; +} + +//override + +- (void)requestApplications:(Request *)request{ + if (request.type == RequestType_Leave && request.number <= 5) { + NSLog(@"%@:%@,数量%ld被批准",self.name,request.content,(long)request.number); + }else{ + if (self.superior) { + [self.superior requestApplications:request]; + } + } +} +@end diff --git a/DesignPatterns/ChainOfResponsibility/Manager.h b/DesignPatterns/ChainOfResponsibility/Manager.h new file mode 100644 index 0000000..7ab1cde --- /dev/null +++ b/DesignPatterns/ChainOfResponsibility/Manager.h @@ -0,0 +1,19 @@ +// +// Manager.h +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "Request.h" +@interface Manager : NSObject + +@property (nonatomic, strong) NSString *name; +@property (nonatomic, strong) Manager *superior; + +- (void)settingSuperior:(Manager *)superior; +- (void)requestApplications:(Request *)request; + +@end diff --git a/DesignPatterns/ChainOfResponsibility/Manager.m b/DesignPatterns/ChainOfResponsibility/Manager.m new file mode 100644 index 0000000..ac633e4 --- /dev/null +++ b/DesignPatterns/ChainOfResponsibility/Manager.m @@ -0,0 +1,21 @@ +// +// Manager.m +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Manager.h" + +@implementation Manager + +- (void)settingSuperior:(Manager *)superior{ + self.superior = superior; +} + +- (void)requestApplications:(Request *)request{ + +} + +@end diff --git a/DesignPatterns/ChainOfResponsibility/Request.h b/DesignPatterns/ChainOfResponsibility/Request.h new file mode 100644 index 0000000..99ea098 --- /dev/null +++ b/DesignPatterns/ChainOfResponsibility/Request.h @@ -0,0 +1,29 @@ +// +// Request.h +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import + +typedef NS_ENUM(NSUInteger, RequestType) { + RequestType_Leave,//请假 + RequestType_SalaryRaise,//加薪 +}; + +//typedef NS_ENUM(NSUInteger, RequestContent) { +// RequestContent_SalaryRaise,//加薪 +//}; + +@interface Request : NSObject + +- (instancetype)initWithType:(RequestType)type content:(NSString *)content number:(NSInteger)number; + +@property (nonatomic, assign) NSInteger number; +@property (nonatomic, assign) RequestType type; +@property (nonatomic, copy) NSString *content; + +//@property (nonatomic, assign) RequestContent content; +@end diff --git a/DesignPatterns/ChainOfResponsibility/Request.m b/DesignPatterns/ChainOfResponsibility/Request.m new file mode 100644 index 0000000..54cb0c4 --- /dev/null +++ b/DesignPatterns/ChainOfResponsibility/Request.m @@ -0,0 +1,21 @@ +// +// Request.m +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Request.h" + +@implementation Request +- (instancetype)initWithType:(RequestType)type content:(NSString *)content number:(NSInteger)number{ + self = [super init]; + if (self) { + self.type = type; + self.content = content; + self.number = number; + } + return self; +} +@end diff --git a/DesignPatterns/Command/BakeChickenWingCommand.h b/DesignPatterns/Command/BakeChickenWingCommand.h new file mode 100644 index 0000000..cc56ce6 --- /dev/null +++ b/DesignPatterns/Command/BakeChickenWingCommand.h @@ -0,0 +1,15 @@ +// +// BakeChickenWingCommand.h +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "Command.h" +#import "Barbecuer.h" +@interface BakeChickenWingCommand : NSObject + +- (instancetype)initBakeChickenWingCommand:(Barbecuer *)receiver; +@end diff --git a/DesignPatterns/Command/BakeChickenWingCommand.m b/DesignPatterns/Command/BakeChickenWingCommand.m new file mode 100644 index 0000000..43e06f0 --- /dev/null +++ b/DesignPatterns/Command/BakeChickenWingCommand.m @@ -0,0 +1,29 @@ +// +// BakeChickenWingCommand.m +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "BakeChickenWingCommand.h" + +@interface BakeChickenWingCommand () +@property (nonatomic, strong) Barbecuer *receiver; +@end + +@implementation BakeChickenWingCommand + + +- (instancetype)initBakeChickenWingCommand:(Barbecuer *)receiver{ + self = [super init]; + if (self) { + self.receiver = receiver; + } + return self; +} + +- (void)excuteCommand{ + [self.receiver bakeMutton]; +} +@end diff --git a/DesignPatterns/Command/BakeMuttonCommand.h b/DesignPatterns/Command/BakeMuttonCommand.h new file mode 100644 index 0000000..c8a79ba --- /dev/null +++ b/DesignPatterns/Command/BakeMuttonCommand.h @@ -0,0 +1,17 @@ +// +// BakeMuttonCommand.h +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "Command.h" +#import "Barbecuer.h" +@interface BakeMuttonCommand : NSObject + + +- (instancetype)initBakeMuttonCommand:(Barbecuer *)receiver; + +@end diff --git a/DesignPatterns/Command/BakeMuttonCommand.m b/DesignPatterns/Command/BakeMuttonCommand.m new file mode 100644 index 0000000..1785877 --- /dev/null +++ b/DesignPatterns/Command/BakeMuttonCommand.m @@ -0,0 +1,30 @@ +// +// BakeMuttonCommand.m +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "BakeMuttonCommand.h" + +@interface BakeMuttonCommand () +@property (nonatomic, strong) Barbecuer *receiver; +@end + +@implementation BakeMuttonCommand + + +- (instancetype)initBakeMuttonCommand:(Barbecuer *)receiver{ + self = [super init]; + if (self) { + self.receiver = receiver; + } + return self; +} + +- (void)excuteCommand{ + [self.receiver bakeMutton]; +} + +@end diff --git a/DesignPatterns/Command/Barbecuer.h b/DesignPatterns/Command/Barbecuer.h new file mode 100644 index 0000000..fff58e5 --- /dev/null +++ b/DesignPatterns/Command/Barbecuer.h @@ -0,0 +1,16 @@ +// +// Barbecuer.h +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import + +@interface Barbecuer : NSObject + +- (void)bakeMutton; +- (void)bakeChickenWing; + +@end diff --git a/DesignPatterns/Command/Barbecuer.m b/DesignPatterns/Command/Barbecuer.m new file mode 100644 index 0000000..f041180 --- /dev/null +++ b/DesignPatterns/Command/Barbecuer.m @@ -0,0 +1,18 @@ +// +// Barbecuer.m +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Barbecuer.h" + +@implementation Barbecuer +- (void)bakeMutton{ + NSLog(@"烤羊肉串"); +} +- (void)bakeChickenWing{ + NSLog(@"烤鸡翅"); +} +@end diff --git a/DesignPatterns/Command/Command.h b/DesignPatterns/Command/Command.h new file mode 100644 index 0000000..a849e8e --- /dev/null +++ b/DesignPatterns/Command/Command.h @@ -0,0 +1,15 @@ +// +// Command.h +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +//#import "Barbecuer.h" +@protocol Command + +- (void)excuteCommand; + +@end diff --git a/DesignPatterns/Command/Waiter.h b/DesignPatterns/Command/Waiter.h new file mode 100644 index 0000000..38b2878 --- /dev/null +++ b/DesignPatterns/Command/Waiter.h @@ -0,0 +1,17 @@ +// +// Waiter.h +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "Command.h" +@interface Waiter : NSObject + +- (void)setOrder:(id)command; +- (void)cancelOrder:(id)command; +- (void)notify; + +@end diff --git a/DesignPatterns/Command/Waiter.m b/DesignPatterns/Command/Waiter.m new file mode 100644 index 0000000..e61dff1 --- /dev/null +++ b/DesignPatterns/Command/Waiter.m @@ -0,0 +1,50 @@ +// +// Waiter.m +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Waiter.h" + +@interface Waiter () +@property (nonatomic, strong) NSMutableArray> *orders; + +@end + +@implementation Waiter + +- (NSMutableArray *)orders{ + if (!_orders) { + _orders = @[].mutableCopy; + } + return _orders; +} + +- (void)setOrder:(id)command{ + + if ([command isKindOfClass:[NSClassFromString(@"BakeChickenWingCommand") class]]) { + NSLog(@"增加订单:烤鸡翅!-^-...-^- 服务员:鸡翅没有了,请点别的烧烤"); + }else{ + [self.orders addObject:command]; + if ([command isKindOfClass:[NSClassFromString(@"BakeChickenWingCommand") class]]) { + NSLog(@"增加订单:烤鸡翅!"); + }else if([command isKindOfClass:[NSClassFromString(@"BakeMuttonCommand") class]]){ + NSLog(@"增加订单:烤羊肉串!"); + } + } +} + + +- (void)cancelOrder:(id)command{ + [self.orders removeObject:command]; +} + +- (void)notify{ + [self.orders enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + [obj excuteCommand]; + }]; +} + +@end diff --git "a/DesignPatterns/Composite\347\273\204\345\220\210/Component.h" "b/DesignPatterns/Composite\347\273\204\345\220\210/Component.h" new file mode 100644 index 0000000..22dac21 --- /dev/null +++ "b/DesignPatterns/Composite\347\273\204\345\220\210/Component.h" @@ -0,0 +1,21 @@ +// +// Component.h +// DesignPatterns +// +// Created by RenPeng on 16/8/26. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import + +@interface Component : NSObject + +@property (nonatomic, copy) NSString *name; + +- (instancetype)initWithName:(NSString *)name; + +- (void)add:(Component *)c; +- (void)remove:(Component *)c; +- (void)display:(int)depth; + +@end diff --git "a/DesignPatterns/Composite\347\273\204\345\220\210/Component.m" "b/DesignPatterns/Composite\347\273\204\345\220\210/Component.m" new file mode 100644 index 0000000..2ae16bb --- /dev/null +++ "b/DesignPatterns/Composite\347\273\204\345\220\210/Component.m" @@ -0,0 +1,33 @@ +// +// Component.m +// DesignPatterns +// +// Created by RenPeng on 16/8/26. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Component.h" + +@implementation Component + +- (instancetype)initWithName:(NSString *)name{ + self = [super init]; + if (self) { + self.name = name; + } + return self; +} + +- (void)add:(Component *)c{ + +} + +- (void)remove:(Component *)c{ + +} + +- (void)display:(int)depth{ + +} + +@end diff --git "a/DesignPatterns/Composite\347\273\204\345\220\210/Composite.h" "b/DesignPatterns/Composite\347\273\204\345\220\210/Composite.h" new file mode 100644 index 0000000..61d5e3b --- /dev/null +++ "b/DesignPatterns/Composite\347\273\204\345\220\210/Composite.h" @@ -0,0 +1,14 @@ +// +// Composite.h +// DesignPatterns +// +// Created by RenPeng on 16/8/26. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Component.h" + +@interface Composite : Component + +- (instancetype)initCompositeWithName:(NSString *)name; +@end diff --git "a/DesignPatterns/Composite\347\273\204\345\220\210/Composite.m" "b/DesignPatterns/Composite\347\273\204\345\220\210/Composite.m" new file mode 100644 index 0000000..11bc667 --- /dev/null +++ "b/DesignPatterns/Composite\347\273\204\345\220\210/Composite.m" @@ -0,0 +1,51 @@ +// +// Composite.m +// DesignPatterns +// +// Created by RenPeng on 16/8/26. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Composite.h" + +@interface Composite () +@property (nonatomic, strong) NSMutableArray *children; +@end + +@implementation Composite + +- (NSMutableArray *)children{ + if (!_children) { + _children = @[].mutableCopy; + } + return _children; +} + +- (instancetype)initCompositeWithName:(NSString *)name{ + self = [super initWithName:name]; + if (self) { + self.name = name; + } + return self; +} + +- (void)add:(Component *)c{ + [self.children addObject:c]; +} + +- (void)remove:(Component *)c{ + [self.children removeObject:c]; +} + +- (void)display:(int)depth{ + for (int i = 0; i < depth; i++) { + self.name = [NSString stringWithFormat:@"-%@",self.name]; + } + NSLog(@"%@",self.name); + + [self.children enumerateObjectsUsingBlock:^(Component * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + [obj display:depth + 2]; + }]; +} + +@end diff --git "a/DesignPatterns/Composite\347\273\204\345\220\210/Leaf.h" "b/DesignPatterns/Composite\347\273\204\345\220\210/Leaf.h" new file mode 100644 index 0000000..4fea426 --- /dev/null +++ "b/DesignPatterns/Composite\347\273\204\345\220\210/Leaf.h" @@ -0,0 +1,16 @@ +// +// Leaf.h +// DesignPatterns +// +// Created by RenPeng on 16/8/26. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Component.h" + +@interface Leaf : Component + + +- (instancetype)initWithName:(NSString *)name; + +@end diff --git "a/DesignPatterns/Composite\347\273\204\345\220\210/Leaf.m" "b/DesignPatterns/Composite\347\273\204\345\220\210/Leaf.m" new file mode 100644 index 0000000..ef28dad --- /dev/null +++ "b/DesignPatterns/Composite\347\273\204\345\220\210/Leaf.m" @@ -0,0 +1,36 @@ +// +// Leaf.m +// DesignPatterns +// +// Created by RenPeng on 16/8/26. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Leaf.h" + +@implementation Leaf + +- (instancetype)initWithName:(NSString *)name{ + self = [super initWithName:name]; + if (self) { + self.name = name; + } + return self; +} + +- (void)add:(Component *)c{ + NSLog(@"Cannot add to a leaf"); +} + +- (void)remove:(Component *)c{ + NSLog(@"Cannot remove from a leaf"); +} + +- (void)display:(int)depth{ + for (int i = 0; i < depth; i++) { + self.name = [NSString stringWithFormat:@"-%@",self.name]; + } + NSLog(@"%@",self.name); +} + +@end diff --git "a/DesignPatterns/Decorator\350\243\205\351\245\260/BigTrouser.h" "b/DesignPatterns/Decorator\350\243\205\351\245\260/BigTrouser.h" new file mode 100644 index 0000000..734777f --- /dev/null +++ "b/DesignPatterns/Decorator\350\243\205\351\245\260/BigTrouser.h" @@ -0,0 +1,13 @@ +// +// BigTrouser.h +// DesignPatterns +// +// Created by RenPeng on 16/8/23. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Finery.h" + +@interface BigTrouser : Finery + +@end diff --git "a/DesignPatterns/Decorator\350\243\205\351\245\260/BigTrouser.m" "b/DesignPatterns/Decorator\350\243\205\351\245\260/BigTrouser.m" new file mode 100644 index 0000000..6e5a3c8 --- /dev/null +++ "b/DesignPatterns/Decorator\350\243\205\351\245\260/BigTrouser.m" @@ -0,0 +1,19 @@ +// +// BigTrouser.m +// DesignPatterns +// +// Created by RenPeng on 16/8/23. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "BigTrouser.h" + +@implementation BigTrouser + +- (void)show{ + NSLog(@"垮裤"); + [super show]; +} + + +@end diff --git "a/DesignPatterns/Decorator\350\243\205\351\245\260/Finery.h" "b/DesignPatterns/Decorator\350\243\205\351\245\260/Finery.h" new file mode 100644 index 0000000..7468cc9 --- /dev/null +++ "b/DesignPatterns/Decorator\350\243\205\351\245\260/Finery.h" @@ -0,0 +1,19 @@ +// +// Finery.h +// DesignPatterns +// +// Created by RenPeng on 16/8/23. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Person.h" + +@interface Finery : Person + +- (instancetype)initWithDecorate:(Person *)component; + +@end + +@interface Sneakers : Finery + +@end \ No newline at end of file diff --git "a/DesignPatterns/Decorator\350\243\205\351\245\260/Finery.m" "b/DesignPatterns/Decorator\350\243\205\351\245\260/Finery.m" new file mode 100644 index 0000000..4ee48f2 --- /dev/null +++ "b/DesignPatterns/Decorator\350\243\205\351\245\260/Finery.m" @@ -0,0 +1,46 @@ +// +// Finery.m +// DesignPatterns +// +// Created by RenPeng on 16/8/23. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Finery.h" + +@interface Finery () + +@property (nonatomic, strong) Person *component; + +@end + +@implementation Finery + + +- (instancetype)initWithDecorate:(Person *)component{ + self = [super init]; + if (self) { + self.component = component; + } + return self; +} + +- (void)show{ + if (self.component) { + [self.component show]; + } +} + +@end + + +@implementation Sneakers + +- (void)show{ + NSLog(@"破球鞋"); + [super show]; +} + +@end + + diff --git "a/DesignPatterns/Decorator\350\243\205\351\245\260/Person.h" "b/DesignPatterns/Decorator\350\243\205\351\245\260/Person.h" new file mode 100644 index 0000000..c794887 --- /dev/null +++ "b/DesignPatterns/Decorator\350\243\205\351\245\260/Person.h" @@ -0,0 +1,22 @@ +// +// Person.h +// DesignPatterns +// +// Created by RenPeng on 16/8/23. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import + +@protocol Component + +- (void)show; + +@end + + +@interface Person : NSObject + +- (instancetype)initWithName:(NSString *)name; + +@end diff --git "a/DesignPatterns/Decorator\350\243\205\351\245\260/Person.m" "b/DesignPatterns/Decorator\350\243\205\351\245\260/Person.m" new file mode 100644 index 0000000..97cdc57 --- /dev/null +++ "b/DesignPatterns/Decorator\350\243\205\351\245\260/Person.m" @@ -0,0 +1,31 @@ +// +// Person.m +// DesignPatterns +// +// Created by RenPeng on 16/8/23. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Person.h" + +@interface Person () + +@property (nonatomic, copy) NSString *name; + +@end + +@implementation Person + +- (instancetype)initWithName:(NSString *)name{ + self = [super init]; + if (self) { + self.name = name; + } + return self; +} + +- (void)show{ + NSLog(@"装饰者:%@",self.name); +} + +@end diff --git "a/DesignPatterns/Decorator\350\243\205\351\245\260/TShirts.h" "b/DesignPatterns/Decorator\350\243\205\351\245\260/TShirts.h" new file mode 100644 index 0000000..54c9506 --- /dev/null +++ "b/DesignPatterns/Decorator\350\243\205\351\245\260/TShirts.h" @@ -0,0 +1,13 @@ +// +// TShirts.h +// DesignPatterns +// +// Created by RenPeng on 16/8/23. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Finery.h" + +@interface TShirts : Finery + +@end diff --git "a/DesignPatterns/Decorator\350\243\205\351\245\260/TShirts.m" "b/DesignPatterns/Decorator\350\243\205\351\245\260/TShirts.m" new file mode 100644 index 0000000..622a902 --- /dev/null +++ "b/DesignPatterns/Decorator\350\243\205\351\245\260/TShirts.m" @@ -0,0 +1,18 @@ +// +// TShirts.m +// DesignPatterns +// +// Created by RenPeng on 16/8/23. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "TShirts.h" + +@implementation TShirts + +- (void)show{ + NSLog(@"大T恤"); + [super show]; +} + +@end diff --git a/DesignPatterns/Flyweight/ConcerteWebSite.h b/DesignPatterns/Flyweight/ConcerteWebSite.h new file mode 100644 index 0000000..59727a5 --- /dev/null +++ b/DesignPatterns/Flyweight/ConcerteWebSite.h @@ -0,0 +1,13 @@ +// +// ConcerteWebSite.h +// DesignPatterns +// +// Created by RenPeng on 16/8/18. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "WebSite.h" +@interface ConcerteWebSite : NSObject +- (instancetype)initConcerteWebSiteWithName:(NSString *)name; +@end diff --git a/DesignPatterns/Flyweight/ConcerteWebSite.m b/DesignPatterns/Flyweight/ConcerteWebSite.m new file mode 100644 index 0000000..1e45a42 --- /dev/null +++ b/DesignPatterns/Flyweight/ConcerteWebSite.m @@ -0,0 +1,29 @@ +// +// ConcerteWebSite.m +// DesignPatterns +// +// Created by RenPeng on 16/8/18. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "ConcerteWebSite.h" +#import "FlyweightUser.h" +@interface ConcerteWebSite () +@property (copy, nonatomic) NSString *name; +@end + +@implementation ConcerteWebSite + +- (instancetype)initConcerteWebSiteWithName:(NSString *)name{ + self = [super init]; + if (self) { + self.name = name; + } + return self; +} + +- (void)Use:(FlyweightUser *)user{ + NSLog(@"网站分类:%@ 用户:%@",self.name,user.name); +} + +@end diff --git a/DesignPatterns/Flyweight/FlyweightUser.h b/DesignPatterns/Flyweight/FlyweightUser.h new file mode 100644 index 0000000..d7ec32c --- /dev/null +++ b/DesignPatterns/Flyweight/FlyweightUser.h @@ -0,0 +1,17 @@ +// +// User.h +// DesignPatterns +// +// Created by RenPeng on 16/8/18. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import + +@interface FlyweightUser : NSObject + +@property (copy, nonatomic, readonly) NSString *name; + +- (instancetype)initUser:(NSString *)name; + +@end diff --git a/DesignPatterns/Flyweight/FlyweightUser.m b/DesignPatterns/Flyweight/FlyweightUser.m new file mode 100644 index 0000000..4cd02e8 --- /dev/null +++ b/DesignPatterns/Flyweight/FlyweightUser.m @@ -0,0 +1,26 @@ +// +// User.m +// DesignPatterns +// +// Created by RenPeng on 16/8/18. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "FlyweightUser.h" + +@interface FlyweightUser () + +@property (copy, nonatomic, readwrite) NSString *name; + +@end + +@implementation FlyweightUser + +- (instancetype)initUser:(NSString *)name{ + self = [super init]; + if (self) { + self.name = name; + } + return self; +} +@end diff --git a/DesignPatterns/Flyweight/WebSite.h b/DesignPatterns/Flyweight/WebSite.h new file mode 100644 index 0000000..5727487 --- /dev/null +++ b/DesignPatterns/Flyweight/WebSite.h @@ -0,0 +1,13 @@ +// +// WebSite.h +// DesignPatterns +// +// Created by RenPeng on 16/8/18. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +@class FlyweightUser; +@protocol WebSite +- (void)Use:(FlyweightUser *)user; +@end diff --git a/DesignPatterns/Flyweight/WebSiteFactory.h b/DesignPatterns/Flyweight/WebSiteFactory.h new file mode 100644 index 0000000..c542f2b --- /dev/null +++ b/DesignPatterns/Flyweight/WebSiteFactory.h @@ -0,0 +1,21 @@ +// +// WebSiteFactory.h +// DesignPatterns +// +// Created by RenPeng on 16/8/18. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "WebSite.h" +@interface WebSiteFactory : NSObject +/** + * 获得网站分类 + */ +- (id)getWebSiteCategory:(NSString *)key; + +/** + * 获得网站分类总数 + */ +- (NSInteger)getWebSitrCount; +@end diff --git a/DesignPatterns/Flyweight/WebSiteFactory.m b/DesignPatterns/Flyweight/WebSiteFactory.m new file mode 100644 index 0000000..55109e4 --- /dev/null +++ b/DesignPatterns/Flyweight/WebSiteFactory.m @@ -0,0 +1,37 @@ +// +// WebSiteFactory.m +// DesignPatterns +// +// Created by RenPeng on 16/8/18. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "WebSiteFactory.h" +#import "ConcerteWebSite.h" + +@interface WebSiteFactory () +@property (strong, nonatomic) NSMutableDictionary *dic; +@end +@implementation WebSiteFactory + +- (NSMutableDictionary *)dic{ + if (!_dic) { + _dic = [[NSMutableDictionary alloc] init]; + } + return _dic; +} + +- (id)getWebSiteCategory:(NSString *)key{ + if (![self.dic objectForKey:key]) { + [self.dic setObject:[[ConcerteWebSite alloc] initConcerteWebSiteWithName:key] forKey:key]; + } + return [self.dic objectForKey:key]; +} + + +- (NSInteger)getWebSitrCount{ + return self.dic.allKeys.count; +} + + +@end diff --git "a/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Expression.h" "b/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Expression.h" new file mode 100644 index 0000000..c843a59 --- /dev/null +++ "b/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Expression.h" @@ -0,0 +1,16 @@ +// +// Expression.h +// DesignPatterns +// +// Created by RenPeng on 16/8/30. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "PlayContext.h" +@interface Expression : NSObject + +- (void)interpret:(PlayContext *)context; +- (void)excute:(NSString *)key value:(double)value; + +@end diff --git "a/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Expression.m" "b/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Expression.m" new file mode 100644 index 0000000..ac495cd --- /dev/null +++ "b/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Expression.m" @@ -0,0 +1,28 @@ +// +// Expression.m +// DesignPatterns +// +// Created by RenPeng on 16/8/30. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Expression.h" + +@implementation Expression + +- (void)interpret:(PlayContext *)context{ + if (context.playText.length == 0) { + return; + }else{ + NSString *playKey = [context.playText substringWithRange:NSMakeRange(0, 1)]; + double playValue = [[context.playText substringWithRange:NSMakeRange(2, 1)] doubleValue]; + context.playText = [context.playText substringFromIndex:4]; + [self excute:playKey value:playValue]; + } +} + +- (void)excute:(NSString *)key value:(double)value{ + +} + +@end diff --git "a/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Note.h" "b/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Note.h" new file mode 100644 index 0000000..18b333a --- /dev/null +++ "b/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Note.h" @@ -0,0 +1,13 @@ +// +// Note.h +// DesignPatterns +// +// Created by RenPeng on 16/8/30. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Expression.h" + +@interface Note : Expression + +@end diff --git "a/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Note.m" "b/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Note.m" new file mode 100644 index 0000000..58ab562 --- /dev/null +++ "b/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Note.m" @@ -0,0 +1,35 @@ +// +// Note.m +// DesignPatterns +// +// Created by RenPeng on 16/8/30. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Note.h" + +@implementation Note + +- (void)excute:(NSString *)key value:(double)value{ + NSString *note = @""; + if ([key isEqualToString:@"C"]) { + note = @"1"; + }else if ([key isEqualToString:@"D"]){ + note = @"2"; + }else if ([key isEqualToString:@"E"]){ + note = @"3"; + }else if ([key isEqualToString:@"F"]){ + note = @"4"; + }else if ([key isEqualToString:@"G"]){ + note = @"5"; + }else if ([key isEqualToString:@"A"]){ + note = @"6"; + }else if ([key isEqualToString:@"B"]){ + note = @"7"; + } + NSLog(@"note:%@",note); +} + + + +@end diff --git "a/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/PlayContext.h" "b/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/PlayContext.h" new file mode 100644 index 0000000..a8e8ffe --- /dev/null +++ "b/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/PlayContext.h" @@ -0,0 +1,13 @@ +// +// PlayContext.h +// DesignPatterns +// +// Created by RenPeng on 16/8/30. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import + +@interface PlayContext : NSObject +@property (nonatomic, strong) NSString *playText; +@end diff --git "a/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/PlayContext.m" "b/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/PlayContext.m" new file mode 100644 index 0000000..b9b331c --- /dev/null +++ "b/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/PlayContext.m" @@ -0,0 +1,13 @@ +// +// PlayContext.m +// DesignPatterns +// +// Created by RenPeng on 16/8/30. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "PlayContext.h" + +@implementation PlayContext + +@end diff --git "a/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Scale.h" "b/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Scale.h" new file mode 100644 index 0000000..8971fa3 --- /dev/null +++ "b/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Scale.h" @@ -0,0 +1,13 @@ +// +// Scale.h +// DesignPatterns +// +// Created by RenPeng on 16/8/30. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Expression.h" + +@interface Scale : Expression + +@end diff --git "a/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Scale.m" "b/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Scale.m" new file mode 100644 index 0000000..39b219d --- /dev/null +++ "b/DesignPatterns/Interpreter\350\247\243\351\207\212\345\231\250/Scale.m" @@ -0,0 +1,31 @@ +// +// Scale.m +// DesignPatterns +// +// Created by RenPeng on 16/8/30. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Scale.h" + +@implementation Scale + +- (void)excute:(NSString *)key value:(double)value{ + NSString *scale = @""; + switch ((int)value) { + case 1: + scale = @"低音"; + break; + case 2: + scale = @"中音"; + break; + case 3: + scale = @"高音"; + break; + default: + break; + } + NSLog(@"scale:%@",scale); +} + +@end diff --git "a/DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/Aggregate.h" "b/DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/Aggregate.h" new file mode 100644 index 0000000..14d3a19 --- /dev/null +++ "b/DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/Aggregate.h" @@ -0,0 +1,16 @@ +// +// Aggregate.h +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "Iterator.h" + +@protocol Aggregate + +- (id)createIterator; + +@end diff --git "a/DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/ConcreteAggregate.h" "b/DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/ConcreteAggregate.h" new file mode 100644 index 0000000..ad1ef58 --- /dev/null +++ "b/DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/ConcreteAggregate.h" @@ -0,0 +1,19 @@ +// +// ConcreteAggregate.h +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "Aggregate.h" + +@interface ConcreteAggregate : NSObject + +@property (nonatomic, strong) NSMutableArray *items; +@property (nonatomic, assign, readonly) NSInteger count; + +- (void)addObjectWithName:(NSString *)name index:(NSInteger)index; + +@end diff --git "a/DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/ConcreteAggregate.m" "b/DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/ConcreteAggregate.m" new file mode 100644 index 0000000..5a19ee6 --- /dev/null +++ "b/DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/ConcreteAggregate.m" @@ -0,0 +1,39 @@ +// +// ConcreteAggregate.m +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "ConcreteAggregate.h" +#import "Iterator.h" +#import "ConcreteIterator.h" + +@implementation ConcreteAggregate + +/** + * 懒加载 + */ +- (NSMutableArray *)items{ + if (!_items) { + _items = @[].mutableCopy; + } + return _items; +} + +- (void)addObjectWithName:(NSString *)name index:(NSInteger)index{ + [self.items insertObject:name atIndex:index]; +} + +- (id)createIterator{ + return [[ConcreteIterator alloc] initConcreteIterator:self]; +} + +- (NSInteger)count{ + return self.items.count; +} + + + +@end diff --git "a/DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/ConcreteIterator.h" "b/DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/ConcreteIterator.h" new file mode 100644 index 0000000..0235c1d --- /dev/null +++ "b/DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/ConcreteIterator.h" @@ -0,0 +1,17 @@ +// +// ConcreteIterator.h +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "Iterator.h" +#import "ConcreteAggregate.h" + +@interface ConcreteIterator : NSObject + +- (instancetype)initConcreteIterator:(ConcreteAggregate *)aggregate; + +@end diff --git "a/DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/ConcreteIterator.m" "b/DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/ConcreteIterator.m" new file mode 100644 index 0000000..88bfdd0 --- /dev/null +++ "b/DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/ConcreteIterator.m" @@ -0,0 +1,49 @@ +// +// ConcreteIterator.m +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "ConcreteIterator.h" + +@interface ConcreteIterator () + +@property (nonatomic, strong) ConcreteAggregate *aggregate; +@property (nonatomic, assign) NSInteger current; + +@end + +@implementation ConcreteIterator + +- (instancetype)initConcreteIterator:(ConcreteAggregate *)aggregate{ + self = [super init]; + if (self) { + self.aggregate = aggregate; + } + return self; +} + +- (id)first{ + return self.aggregate.items[0]; +} + +- (id)next { + NSString *name = @""; + self.current++; + if (self.current < self.aggregate.count) { + name = self.aggregate.items[self.current]; + } + return name; +} + +- (BOOL)isDone{ + return self.current >= self.aggregate.count ? YES : NO; +} + +- (id)currentItem{ + return self.aggregate.items[self.current]; +} + +@end diff --git "a/DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/Iterator.h" "b/DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/Iterator.h" new file mode 100644 index 0000000..36eefa8 --- /dev/null +++ "b/DesignPatterns/Iterator\350\277\255\344\273\243\345\231\250/Iterator.h" @@ -0,0 +1,18 @@ +// +// Iterator.h +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import + +@protocol Iterator + +- (id)first; +- (id)next; +- (BOOL)isDone; +- (id)currentItem; + +@end diff --git "a/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/Country.h" "b/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/Country.h" new file mode 100644 index 0000000..1a514b5 --- /dev/null +++ "b/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/Country.h" @@ -0,0 +1,17 @@ +// +// Country.h +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "UnitedNations.h" +@interface Country : NSObject + +@property (nonatomic, strong) id mediator; + +- (instancetype)initCountryWithUnitedNations:(id)mediator; + +@end diff --git "a/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/Country.m" "b/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/Country.m" new file mode 100644 index 0000000..315e3e0 --- /dev/null +++ "b/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/Country.m" @@ -0,0 +1,20 @@ +// +// Country.m +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Country.h" + +@implementation Country + +- (instancetype)initCountryWithUnitedNations:(id)mediator{ + self = [super init]; + if (self) { + self.mediator = mediator; + } + return self; +} +@end diff --git "a/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/Iraq.h" "b/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/Iraq.h" new file mode 100644 index 0000000..981c144 --- /dev/null +++ "b/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/Iraq.h" @@ -0,0 +1,14 @@ +// +// Iraq.h +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Country.h" + +@interface Iraq : Country +- (void)declare:(NSString *)message; +- (void)getMessage:(NSString *)message; +@end diff --git "a/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/Iraq.m" "b/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/Iraq.m" new file mode 100644 index 0000000..a33adba --- /dev/null +++ "b/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/Iraq.m" @@ -0,0 +1,18 @@ +// +// Iraq.m +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Iraq.h" + +@implementation Iraq +- (void)declare:(NSString *)message{ + [self.mediator declare:message country:self]; +} +- (void)getMessage:(NSString *)message{ + NSLog(@"伊拉克获得对方信息:%@",message); +} +@end diff --git "a/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/USA.h" "b/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/USA.h" new file mode 100644 index 0000000..c78f50c --- /dev/null +++ "b/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/USA.h" @@ -0,0 +1,15 @@ +// +// USA.h +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Country.h" + +@interface USA : Country + +- (void)declare:(NSString *)message; +- (void)getMessage:(NSString *)message; +@end diff --git "a/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/USA.m" "b/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/USA.m" new file mode 100644 index 0000000..7cfd8e1 --- /dev/null +++ "b/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/USA.m" @@ -0,0 +1,18 @@ +// +// USA.m +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "USA.h" + +@implementation USA +- (void)declare:(NSString *)message{ + [self.mediator declare:message country:self]; +} +- (void)getMessage:(NSString *)message{ + NSLog(@"美国获得对方信息:%@",message); +} +@end diff --git "a/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/UnitedNations.h" "b/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/UnitedNations.h" new file mode 100644 index 0000000..97b3f55 --- /dev/null +++ "b/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/UnitedNations.h" @@ -0,0 +1,16 @@ +// +// UnitedNations.h +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import + +@class Country; +@protocol UnitedNations + +- (void)declare:(NSString *)message country:(Country *)country; + +@end diff --git "a/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/UnitedNationsSecurityCouncil.h" "b/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/UnitedNationsSecurityCouncil.h" new file mode 100644 index 0000000..22dbba1 --- /dev/null +++ "b/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/UnitedNationsSecurityCouncil.h" @@ -0,0 +1,16 @@ +// +// UnitedNationsSecurityCouncil.h +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "UnitedNations.h" + +@interface UnitedNationsSecurityCouncil : NSObject + + + +@end diff --git "a/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/UnitedNationsSecurityCouncil.m" "b/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/UnitedNationsSecurityCouncil.m" new file mode 100644 index 0000000..acd4532 --- /dev/null +++ "b/DesignPatterns/Mediator\344\270\255\344\273\213\350\200\205/UnitedNationsSecurityCouncil.m" @@ -0,0 +1,24 @@ +// +// UnitedNationsSecurityCouncil.m +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "UnitedNationsSecurityCouncil.h" +#import "Country.h" +#import "USA.h" +#import "Iraq.h" + +@implementation UnitedNationsSecurityCouncil + +- (void)declare:(NSString *)message country:(Country *)country{ + if ([country isKindOfClass:[USA class]]) { + [[[Iraq alloc] initCountryWithUnitedNations:self] getMessage:message]; + }else if ([country isKindOfClass:[Iraq class]]){ + [[[USA alloc] initCountryWithUnitedNations:self] getMessage:message]; + } +} + +@end diff --git "a/DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/GameRole.h" "b/DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/GameRole.h" new file mode 100644 index 0000000..a9a7b24 --- /dev/null +++ "b/DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/GameRole.h" @@ -0,0 +1,27 @@ +// +// GameRole.h +// DesignPatterns +// +// Created by RenPeng on 16/8/25. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "RoleStateMemento.h" +@interface GameRole : NSObject +@property (nonatomic, assign) int vitality; +@property (nonatomic, assign) int attack; +@property (nonatomic, assign) int defense; + +- (void)stateDisplay; + +- (void)getInitState; + +- (void)fight; + +- (RoleStateMemento *)saveState; + +- (void)recoveryState:(RoleStateMemento *)memento; + +@end + diff --git "a/DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/GameRole.m" "b/DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/GameRole.m" new file mode 100644 index 0000000..006bb5e --- /dev/null +++ "b/DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/GameRole.m" @@ -0,0 +1,48 @@ +// +// GameRole.m +// DesignPatterns +// +// Created by RenPeng on 16/8/25. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "GameRole.h" + +@implementation GameRole + +- (instancetype)init +{ + self = [super init]; + if (self) { + [self getInitState]; + } + return self; +} + +- (void)stateDisplay{ + NSLog(@"角色当前状态"); + NSLog(@"体力:%d 攻击力:%d 防御力:%d",self.vitality,self.attack,self.defense); +} + +- (void)getInitState{ + self.vitality = 100; + self.attack = 100; + self.defense = 100; +} + +- (void)fight{ + self.vitality = 0; + self.attack = 0; + self.defense = 0; +} + +- (RoleStateMemento *)saveState{ + return [[RoleStateMemento alloc] initRoleStateMementoWithVitality:self.vitality attack:self.attack defense:self.defense]; +} + +- (void)recoveryState:(RoleStateMemento *)memento{ + self.vitality = memento.vitality; + self.attack = memento.attack; + self.defense = memento.defense; +} +@end diff --git "a/DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/RoleStateCaretaker.h" "b/DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/RoleStateCaretaker.h" new file mode 100644 index 0000000..9277b91 --- /dev/null +++ "b/DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/RoleStateCaretaker.h" @@ -0,0 +1,21 @@ +// +// RoleStateCaretaker.h +// DesignPatterns +// +// Created by RenPeng on 16/8/25. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "RoleStateMemento.h" + +/** + * 角色状态管理者 + */ +@interface RoleStateCaretaker : NSObject + +@property (nonatomic, strong) RoleStateMemento *memento; + +- (instancetype)initRoleStaeCaretakerWithMemento:(RoleStateMemento *)memento; + +@end diff --git "a/DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/RoleStateCaretaker.m" "b/DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/RoleStateCaretaker.m" new file mode 100644 index 0000000..502f900 --- /dev/null +++ "b/DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/RoleStateCaretaker.m" @@ -0,0 +1,23 @@ + +// +// RoleStateCaretaker.m +// DesignPatterns +// +// Created by RenPeng on 16/8/25. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "RoleStateCaretaker.h" + + +@implementation RoleStateCaretaker + + +- (instancetype)initRoleStaeCaretakerWithMemento:(RoleStateMemento *)memento{ + self = [super init]; + if (self) { + self.memento = memento; + } + return self; +} +@end diff --git "a/DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/RoleStateMemento.h" "b/DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/RoleStateMemento.h" new file mode 100644 index 0000000..eed5d25 --- /dev/null +++ "b/DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/RoleStateMemento.h" @@ -0,0 +1,22 @@ +// +// RoleStateMemento.h +// DesignPatterns +// +// Created by RenPeng on 16/8/25. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import + +/** + * 角色状态存储箱类 + */ +@interface RoleStateMemento : NSObject + +@property (nonatomic, assign) int vitality; +@property (nonatomic, assign) int attack; +@property (nonatomic, assign) int defense; + +- (instancetype)initRoleStateMementoWithVitality:(int)vit attack:(int)atk defense:(int)def; + +@end diff --git "a/DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/RoleStateMemento.m" "b/DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/RoleStateMemento.m" new file mode 100644 index 0000000..8ef5240 --- /dev/null +++ "b/DesignPatterns/Memento\345\244\207\345\277\230\345\275\225/RoleStateMemento.m" @@ -0,0 +1,23 @@ +// +// RoleStateMemento.m +// DesignPatterns +// +// Created by RenPeng on 16/8/25. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "RoleStateMemento.h" + +@implementation RoleStateMemento + + +- (instancetype)initRoleStateMementoWithVitality:(int)vit attack:(int)atk defense:(int)def{ + self = [super init]; + if (self) { + self.vitality = vit; + self.attack = atk; + self.defense = def; + } + return self; +} +@end diff --git "a/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/ConcreteObserver.h" "b/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/ConcreteObserver.h" new file mode 100644 index 0000000..49f4400 --- /dev/null +++ "b/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/ConcreteObserver.h" @@ -0,0 +1,18 @@ +// +// ConcreteObserver.h +// DesignPatterns +// +// Created by RenPeng on 16/8/23. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "Observe.h" + +@class ConcreteSubject; + +@interface ConcreteObserver : NSObject + +- (instancetype)initConcreteObserver:(ConcreteSubject *)subject name:(NSString *)name; + +@end diff --git "a/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/ConcreteObserver.m" "b/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/ConcreteObserver.m" new file mode 100644 index 0000000..a2d94ed --- /dev/null +++ "b/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/ConcreteObserver.m" @@ -0,0 +1,35 @@ +// +// ConcreteObserver.m +// DesignPatterns +// +// Created by RenPeng on 16/8/23. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "ConcreteObserver.h" +#import "ConcreteSubject.h" +@interface ConcreteObserver () + +@property (nonatomic, copy) NSString *name; +@property (nonatomic, copy) NSString *observeState; +@property (nonatomic, strong) ConcreteSubject *subject; + +@end + +@implementation ConcreteObserver + +- (instancetype)initConcreteObserver:(ConcreteSubject *)subject name:(NSString *)name{ + self = [super init]; + if (self) { + self.name = name; + self.subject = subject; + } + return self; +} + +- (void)update{ + self.observeState = [self.subject subjectState]; + NSLog(@"观察者%@的新状态是:%@",self.name,self.observeState); +} + +@end diff --git "a/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/ConcreteSubject.h" "b/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/ConcreteSubject.h" new file mode 100644 index 0000000..8aa7f40 --- /dev/null +++ "b/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/ConcreteSubject.h" @@ -0,0 +1,15 @@ +// +// ConcreteSubject.h +// DesignPatterns +// +// Created by RenPeng on 16/8/23. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Subject.h" + +@interface ConcreteSubject : Subject + +@property (nonatomic, copy) NSString *subjectState; + +@end diff --git "a/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/ConcreteSubject.m" "b/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/ConcreteSubject.m" new file mode 100644 index 0000000..eac397f --- /dev/null +++ "b/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/ConcreteSubject.m" @@ -0,0 +1,13 @@ +// +// ConcreteSubject.m +// DesignPatterns +// +// Created by RenPeng on 16/8/23. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "ConcreteSubject.h" + +@implementation ConcreteSubject + +@end diff --git "a/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/Observe.h" "b/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/Observe.h" new file mode 100644 index 0000000..8200efe --- /dev/null +++ "b/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/Observe.h" @@ -0,0 +1,15 @@ +// +// Observe.h +// DesignPatterns +// +// Created by RenPeng on 16/8/23. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import + +@protocol Observe + +- (void)update; + +@end diff --git "a/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/Subject.h" "b/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/Subject.h" new file mode 100644 index 0000000..b35b1af --- /dev/null +++ "b/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/Subject.h" @@ -0,0 +1,17 @@ +// +// Subject.h +// DesignPatterns +// +// Created by RenPeng on 16/8/23. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "Observe.h" + +@interface Subject : NSObject + +- (void)attach:(id)observe; +- (void)notify; + +@end diff --git "a/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/Subject.m" "b/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/Subject.m" new file mode 100644 index 0000000..4a0fa52 --- /dev/null +++ "b/DesignPatterns/Observe\350\247\202\345\257\237\350\200\205/Subject.m" @@ -0,0 +1,36 @@ +// +// Subject.m +// DesignPatterns +// +// Created by RenPeng on 16/8/23. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Subject.h" + +@interface Subject () + +@property (nonatomic, strong) NSMutableArray>* observes; + +@end + +@implementation Subject + +- (NSMutableArray *)observes{ + if (!_observes) { + _observes = @[].mutableCopy; + } + return _observes; +} + +- (void)attach:(id)observe{ + [self.observes addObject:observe]; +} + +- (void)notify{ + [self.observes enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + [obj update]; + }]; +} + +@end diff --git "a/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Action.h" "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Action.h" new file mode 100644 index 0000000..291c178 --- /dev/null +++ "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Action.h" @@ -0,0 +1,20 @@ + +// +// Action.h +// DesignPatterns +// +// Created by RenPeng on 16/8/31. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "Man.h" +#import "Woman.h" + +@protocol Action + +- (void)getManConclusion:(Man *)concreteElementA; + +- (void)getWomanConclusion:(Woman *)concreteElementB; + +@end diff --git "a/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Amativeness.h" "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Amativeness.h" new file mode 100644 index 0000000..860d57b --- /dev/null +++ "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Amativeness.h" @@ -0,0 +1,14 @@ +// +// Amativeness.h +// DesignPatterns +// +// Created by RenPeng on 16/8/31. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "Action.h" + +@interface Amativeness : NSObject + +@end diff --git "a/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Amativeness.m" "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Amativeness.m" new file mode 100644 index 0000000..4e28477 --- /dev/null +++ "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Amativeness.m" @@ -0,0 +1,21 @@ +// +// Amativeness.m +// DesignPatterns +// +// Created by RenPeng on 16/8/31. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Amativeness.h" + +@implementation Amativeness + +- (void)getManConclusion:(Man *)concreteElementA{ + NSLog(@"%@ %@时,凡是不懂也要装懂。",concreteElementA.class,self.class); +} + +- (void)getWomanConclusion:(Woman *)concreteElementB{ + NSLog(@"%@ %@时,凡是懂也装作不懂。",concreteElementB.class,self.class); +} + +@end diff --git "a/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Failing.h" "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Failing.h" new file mode 100644 index 0000000..bafd91c --- /dev/null +++ "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Failing.h" @@ -0,0 +1,14 @@ +// +// Failing.h +// DesignPatterns +// +// Created by RenPeng on 16/8/31. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "Action.h" + +@interface Failing : NSObject + +@end diff --git "a/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Failing.m" "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Failing.m" new file mode 100644 index 0000000..77e8af5 --- /dev/null +++ "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Failing.m" @@ -0,0 +1,21 @@ +// +// Failing.m +// DesignPatterns +// +// Created by RenPeng on 16/8/31. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Failing.h" + +@implementation Failing + +- (void)getManConclusion:(Man *)concreteElementA{ + NSLog(@"%@ %@时,闷头喝酒,谁也不用劝。",concreteElementA.class,self.class); +} + +- (void)getWomanConclusion:(Woman *)concreteElementB{ + NSLog(@"%@ %@时,眼泪汪汪,谁也劝不了。",concreteElementB.class,self.class); +} + +@end diff --git "a/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Man.h" "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Man.h" new file mode 100644 index 0000000..8e82ce5 --- /dev/null +++ "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Man.h" @@ -0,0 +1,14 @@ +// +// Man.h +// DesignPatterns +// +// Created by RenPeng on 16/8/31. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "VisitorPerson.h" + +@interface Man : NSObject + +@end diff --git "a/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Man.m" "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Man.m" new file mode 100644 index 0000000..d502205 --- /dev/null +++ "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Man.m" @@ -0,0 +1,18 @@ +// +// Man.m +// DesignPatterns +// +// Created by RenPeng on 16/8/31. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Man.h" +#import "Action.h" + +@implementation Man + +- (void)accept:(id)visitor{ + [visitor getManConclusion:self]; +} + +@end diff --git "a/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/ObjectStructure.h" "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/ObjectStructure.h" new file mode 100644 index 0000000..a95e4df --- /dev/null +++ "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/ObjectStructure.h" @@ -0,0 +1,19 @@ +// +// ObjectStructure.h +// DesignPatterns +// +// Created by RenPeng on 16/8/31. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "VisitorPerson.h" +#import "Action.h" + +@interface ObjectStructure : NSObject + +- (void)attach:(id)element; +- (void)detach:(id)element; +- (void)display:(id)visitor; + +@end diff --git "a/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/ObjectStructure.m" "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/ObjectStructure.m" new file mode 100644 index 0000000..69dd070 --- /dev/null +++ "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/ObjectStructure.m" @@ -0,0 +1,39 @@ +// +// ObjectStructure.m +// DesignPatterns +// +// Created by RenPeng on 16/8/31. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "ObjectStructure.h" + +@interface ObjectStructure () +@property (nonatomic, strong) NSMutableArray> *elements; +@end + + +@implementation ObjectStructure + +- (NSMutableArray *)elements{ + if (!_elements) { + _elements = @[].mutableCopy; + } + return _elements; +} + +- (void)attach:(id)element{ + [self.elements addObject:element]; +} + +- (void)detach:(id)element{ + [self.elements removeObject:element]; +} + +- (void)display:(id)visitor{ + [self.elements enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + [obj accept:visitor]; + }]; +} + +@end diff --git "a/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Success.h" "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Success.h" new file mode 100644 index 0000000..c256d94 --- /dev/null +++ "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Success.h" @@ -0,0 +1,14 @@ +// +// Success.h +// DesignPatterns +// +// Created by RenPeng on 16/8/31. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "Action.h" + +@interface Success : NSObject + +@end diff --git "a/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Success.m" "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Success.m" new file mode 100644 index 0000000..bd315c4 --- /dev/null +++ "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Success.m" @@ -0,0 +1,21 @@ +// +// Success.m +// DesignPatterns +// +// Created by RenPeng on 16/8/31. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Success.h" + +@implementation Success + +- (void)getManConclusion:(Man *)concreteElementA{ + NSLog(@"%@ %@时,背后多半有一个伟大的女人。",concreteElementA.class,self.class); +} + +- (void)getWomanConclusion:(Woman *)concreteElementB{ + NSLog(@"%@ %@时,背后多半有一个不成功的男人。",concreteElementB.class,self.class); +} + +@end diff --git "a/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/VisitorPerson.h" "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/VisitorPerson.h" new file mode 100644 index 0000000..8e7ce11 --- /dev/null +++ "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/VisitorPerson.h" @@ -0,0 +1,16 @@ +// +// Person.h +// DesignPatterns +// +// Created by RenPeng on 16/8/31. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import + +@protocol Action; +@protocol VisitorPerson + +- (void)accept:(id)visitor; + +@end diff --git "a/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Woman.h" "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Woman.h" new file mode 100644 index 0000000..ae1edc7 --- /dev/null +++ "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Woman.h" @@ -0,0 +1,13 @@ +// +// Woman.h +// DesignPatterns +// +// Created by RenPeng on 16/8/31. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "VisitorPerson.h" +@interface Woman : NSObject + +@end diff --git "a/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Woman.m" "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Woman.m" new file mode 100644 index 0000000..590296b --- /dev/null +++ "b/DesignPatterns/Visitor\350\256\277\351\227\256\350\200\205/Woman.m" @@ -0,0 +1,18 @@ +// +// Woman.m +// DesignPatterns +// +// Created by RenPeng on 16/8/31. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import "Woman.h" +#import "Action.h" + +@implementation Woman + +- (void)accept:(id)visitor{ + [visitor getManConclusion:self]; +} + +@end diff --git "a/DesignPatternsTests/Adapter\351\200\202\351\205\215\345\231\250/Adapter.m" "b/DesignPatternsTests/Adapter\351\200\202\351\205\215\345\231\250/Adapter.m" new file mode 100644 index 0000000..fe3fa9c --- /dev/null +++ "b/DesignPatternsTests/Adapter\351\200\202\351\205\215\345\231\250/Adapter.m" @@ -0,0 +1,48 @@ +// +// Adapter.m +// DesignPatterns +// +// Created by RenPeng on 16/8/24. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "Player.h" +#import "Forwards.h" +#import "Guards.h" +#import "Translator.h" + +@interface Adapter : XCTestCase + +@end + +@implementation Adapter + +- (void)setUp { + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + Player *b = [[Forwards alloc] initWithName:@"巴蒂尔"]; + [b attack]; + Player *m = [[Guards alloc] initWithName:@"麦克格雷迪"]; + [m attack]; + Player *ym = [[Translator alloc] initWithName:@"姚明"]; + [ym attack]; + [ym defense]; +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end diff --git a/DesignPatternsTests/ChainOfResponsibility/ChainOfResponsibility.m b/DesignPatternsTests/ChainOfResponsibility/ChainOfResponsibility.m new file mode 100644 index 0000000..fee5359 --- /dev/null +++ b/DesignPatternsTests/ChainOfResponsibility/ChainOfResponsibility.m @@ -0,0 +1,60 @@ +// +// ChainOfResponsibility.m +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "CommonManager.h" +#import "Majordomo.h" +#import "GeneralManager.h" + +@interface ChainOfResponsibility : XCTestCase + +@end + +@implementation ChainOfResponsibility + +- (void)setUp { + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + CommonManager *jingli = [[CommonManager alloc] initWithName:@"经理"]; + Majordomo *zongjian = [[Majordomo alloc] initWithName:@"总监"]; + GeneralManager *zongjingli = [[GeneralManager alloc] initWithName:@"总经理"]; + [jingli settingSuperior:zongjian]; + [zongjian settingSuperior:zongjingli]; + + Request *request = [[Request alloc] initWithType:RequestType_Leave content:@"小菜请假" number:1]; + [jingli requestApplications:request]; + + Request *request1 = [[Request alloc] initWithType:RequestType_Leave content:@"小菜请假" number:4]; + [jingli requestApplications:request1]; + + Request *request2 = [[Request alloc] initWithType:RequestType_Leave content:@"小菜请假" number:8]; + [jingli requestApplications:request2]; + + Request *request3 = [[Request alloc] initWithType:RequestType_SalaryRaise content:@"小菜请求加薪" number:500]; + [jingli requestApplications:request3]; + + Request *request4 = [[Request alloc] initWithType:RequestType_SalaryRaise content:@"小菜请求加薪" number:1000]; + [jingli requestApplications:request4]; +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end diff --git "a/DesignPatternsTests/Command\345\221\275\344\273\244/Command.m" "b/DesignPatternsTests/Command\345\221\275\344\273\244/Command.m" new file mode 100644 index 0000000..03c50c0 --- /dev/null +++ "b/DesignPatternsTests/Command\345\221\275\344\273\244/Command.m" @@ -0,0 +1,52 @@ +// +// Command.m +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "Barbecuer.h" +#import "BakeMuttonCommand.h" +#import "BakeChickenWingCommand.h" +#import "Waiter.h" +@interface Command : XCTestCase + +@end + +@implementation Command + +- (void)setUp { + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + Barbecuer *boy = [[Barbecuer alloc] init]; + id bakeMuttonCommand1 = [[BakeMuttonCommand alloc] initBakeMuttonCommand:boy]; + id bakeMuttonCommand2 = [[BakeMuttonCommand alloc] initBakeMuttonCommand:boy]; + id bakeChickenWingCommand = [[BakeChickenWingCommand alloc] initBakeChickenWingCommand:boy]; + + Waiter *girl = [[Waiter alloc] init]; + [girl setOrder:bakeMuttonCommand1]; + [girl setOrder:bakeMuttonCommand2]; + [girl setOrder:bakeChickenWingCommand]; + + [girl notify]; + +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end diff --git "a/DesignPatternsTests/Composite\347\273\204\345\220\210/CompositeTest.m" "b/DesignPatternsTests/Composite\347\273\204\345\220\210/CompositeTest.m" new file mode 100644 index 0000000..5381a36 --- /dev/null +++ "b/DesignPatternsTests/Composite\347\273\204\345\220\210/CompositeTest.m" @@ -0,0 +1,61 @@ +// +// CompositeTest.m +// DesignPatterns +// +// Created by RenPeng on 16/8/26. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "Composite.h" +#import "Leaf.h" +@interface CompositeTest : XCTestCase + +@end + +@implementation CompositeTest + +- (void)setUp { + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + Composite *root = [[Composite alloc] initCompositeWithName:@"root"]; + [root add:[[Leaf alloc] initWithName:@"Leaf A"]]; + [root add:[[Leaf alloc] initWithName:@"Leaf B"]]; + + Composite *comp = [[Composite alloc] initCompositeWithName:@"Composite X"]; + [comp add:[[Leaf alloc] initWithName:@"Leaf XA"]]; + [comp add:[[Leaf alloc] initWithName:@"Leaf XB"]]; + + [root add:comp]; + + Composite *comp2 = [[Composite alloc] initCompositeWithName:@"Composite XY"]; + [comp2 add:[[Leaf alloc] initWithName:@"Leaf XYA"]]; + [comp2 add:[[Leaf alloc] initWithName:@"Leaf XYB"]]; + + [comp add:comp2]; + + [root add:[[Leaf alloc] initWithName:@"Leaf C"]]; + + Leaf *leaf = [[Leaf alloc] initWithName:@"Leaf D"]; + [root add:leaf]; + [root remove:leaf]; + + [root display:1]; +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end diff --git "a/DesignPatternsTests/Decorator\350\243\205\351\245\260/Decorator.m" "b/DesignPatternsTests/Decorator\350\243\205\351\245\260/Decorator.m" new file mode 100644 index 0000000..5d84cf8 --- /dev/null +++ "b/DesignPatternsTests/Decorator\350\243\205\351\245\260/Decorator.m" @@ -0,0 +1,37 @@ +// +// Decorator.m +// DesignPatterns +// +// Created by RenPeng on 16/8/23. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "Person.h" +#import "Finery.h" +#import "TShirts.h" +#import "BigTrouser.h" + +@interface Decorator : XCTestCase + +@end + +@implementation Decorator + +- (void)testDecorator { + Person *xc = [[Person alloc] initWithName:@"小菜"]; + NSLog(@"第一种装扮!"); + Sneakers *s = [[Sneakers alloc] initWithDecorate:xc]; + TShirts *t = [[TShirts alloc] initWithDecorate:s]; + BigTrouser *b = [[BigTrouser alloc] initWithDecorate:t]; + [b show]; + + Finery *f = [[Finery alloc] initWithDecorate:xc]; + NSLog(@"第二种装扮!"); + f = [[BigTrouser alloc] initWithDecorate:f]; + f = [[TShirts alloc] initWithDecorate:f]; + f = [[Sneakers alloc] initWithDecorate:f]; + [f show]; +} + +@end diff --git a/DesignPatternsTests/Flyweight/Flyweight.m b/DesignPatternsTests/Flyweight/Flyweight.m new file mode 100644 index 0000000..ae811d2 --- /dev/null +++ b/DesignPatternsTests/Flyweight/Flyweight.m @@ -0,0 +1,44 @@ +// +// Mediator.m +// DesignPatterns +// +// Created by RenPeng on 16/8/18. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import +#import "ConcerteWebSite.h" +#import "WebSiteFactory.h" +#import "FlyweightUser.h" +@interface Flyweight : XCTestCase + +@end + +@implementation Flyweight + +- (void)testMediator{ + WebSiteFactory *f = [[WebSiteFactory alloc] init]; + + ConcerteWebSite *fx = [f getWebSiteCategory:@"产品展示"]; + [fx Use:[[FlyweightUser alloc] initUser:@"小菜"]]; + + ConcerteWebSite *fy = [f getWebSiteCategory:@"产品展示"]; + [fy Use:[[FlyweightUser alloc] initUser:@"大鸟"]]; + + ConcerteWebSite *fz = [f getWebSiteCategory:@"产品展示"]; + [fz Use:[[FlyweightUser alloc] initUser:@"娇娇"]]; + + ConcerteWebSite *fl = [f getWebSiteCategory:@"博客"]; + [fl Use:[[FlyweightUser alloc] initUser:@"老顽童"]]; + + ConcerteWebSite *fm = [f getWebSiteCategory:@"博客"]; + [fm Use:[[FlyweightUser alloc] initUser:@"桃谷六仙"]]; + + ConcerteWebSite *fn = [f getWebSiteCategory:@"博客"]; + [fn Use:[[FlyweightUser alloc] initUser:@"南海鳄神"]]; + + NSLog(@"网站分类总数为:%ld",(long)[f getWebSitrCount]); +} + +@end diff --git "a/DesignPatternsTests/Interpreter\350\247\243\351\207\212\345\231\250/Interpreter.m" "b/DesignPatternsTests/Interpreter\350\247\243\351\207\212\345\231\250/Interpreter.m" new file mode 100644 index 0000000..771f841 --- /dev/null +++ "b/DesignPatternsTests/Interpreter\350\247\243\351\207\212\345\231\250/Interpreter.m" @@ -0,0 +1,47 @@ +// +// Interpreter.m +// DesignPatterns +// +// Created by RenPeng on 16/8/30. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "PlayContext.h" +#import "Expression.h" +#import "Note.h" +#import "Scale.h" + +@interface Interpreter : XCTestCase + +@end + +@implementation Interpreter + +- (void)testExample { + PlayContext *context = [[PlayContext alloc] init]; + context.playText = @"O 2 E 1 A 3 E 1 G 1 D 3 E 1 G 1 A 1 O 3 C 1 O 2 A 1 G 1 C 1 E 1 D 3 "; + + id expression = nil; + while (context.playText.length) { + NSString *str = [context.playText substringWithRange:NSMakeRange(0, 1)]; + if ([str isEqualToString:@"O"]) { + expression = [[Scale alloc] init]; + }else if ([str isEqualToString:@"C"] || [str isEqualToString:@"D"] || [str isEqualToString:@"E"] || [str isEqualToString:@"F"] || [str isEqualToString:@"G"] || [str isEqualToString:@"A"] || [str isEqualToString:@"B"] || [str isEqualToString:@"P"]){ + expression = [[Note alloc] init]; + } + + [expression interpret:context]; + } + + +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end diff --git "a/DesignPatternsTests/Iterator\350\277\255\344\273\243\345\231\250/Iterator.m" "b/DesignPatternsTests/Iterator\350\277\255\344\273\243\345\231\250/Iterator.m" new file mode 100644 index 0000000..b941108 --- /dev/null +++ "b/DesignPatternsTests/Iterator\350\277\255\344\273\243\345\231\250/Iterator.m" @@ -0,0 +1,51 @@ +// +// Iterator.m +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "ConcreteAggregate.h" +#import "ConcreteIterator.h" +@interface Iterator : XCTestCase + +@end + +@implementation Iterator + +- (void)setUp { + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + ConcreteAggregate *a = [[ConcreteAggregate alloc] init]; + [a addObjectWithName:@"大鸟" index:0]; + [a addObjectWithName:@"小菜" index:1]; + [a addObjectWithName:@"行李" index:2]; + [a addObjectWithName:@"老外" index:3]; + [a addObjectWithName:@"内部员工" index:4]; + [a addObjectWithName:@"小偷" index:5]; + + ConcreteIterator *i = [[ConcreteIterator alloc] initConcreteIterator:a]; + while (![i isDone]) { + NSLog(@"%@,请买车票!",[i currentItem]); + [i next]; + } +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end diff --git "a/DesignPatternsTests/Mediator\344\270\255\344\273\213\350\200\205/Mediator.m" "b/DesignPatternsTests/Mediator\344\270\255\344\273\213\350\200\205/Mediator.m" new file mode 100644 index 0000000..b676e77 --- /dev/null +++ "b/DesignPatternsTests/Mediator\344\270\255\344\273\213\350\200\205/Mediator.m" @@ -0,0 +1,45 @@ +// +// Mediator.m +// DesignPatterns +// +// Created by RenPeng on 16/8/29. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "UnitedNationsSecurityCouncil.h" +#import "USA.h" +#import "Iraq.h" +@interface Mediator : XCTestCase + +@end + +@implementation Mediator + +- (void)setUp { + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + UnitedNationsSecurityCouncil *UNSC = [[UnitedNationsSecurityCouncil alloc] init]; + USA *c1 = [[USA alloc] initCountryWithUnitedNations:UNSC]; + Iraq *c2 = [[Iraq alloc] initCountryWithUnitedNations:UNSC]; + + [c1 declare:@"不准研制核武器,否则要发动战争!"]; + [c2 declare:@"我们没有核武器,也不怕侵略。"]; +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end diff --git "a/DesignPatternsTests/Memento\345\244\207\345\277\230\345\275\225/Memento.m" "b/DesignPatternsTests/Memento\345\244\207\345\277\230\345\275\225/Memento.m" new file mode 100644 index 0000000..6bbd472 --- /dev/null +++ "b/DesignPatternsTests/Memento\345\244\207\345\277\230\345\275\225/Memento.m" @@ -0,0 +1,54 @@ +// +// Memento.m +// DesignPatterns +// +// Created by RenPeng on 16/8/25. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "GameRole.h" +#import "RoleStateMemento.h" +#import "RoleStateCaretaker.h" +@interface Memento : XCTestCase + +@end + +@implementation Memento + +- (void)setUp { + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + //大战Boss前 + GameRole *gr = [[GameRole alloc] init]; + [gr getInitState]; + [gr stateDisplay]; + + //保存进度 + RoleStateCaretaker *stateAdmin = [[RoleStateCaretaker alloc] initRoleStaeCaretakerWithMemento:[gr saveState]]; + + //大战Boss时,损耗严重 + [gr fight]; + [gr stateDisplay]; + + //恢复之前状态 + [gr recoveryState:stateAdmin.memento]; + [gr stateDisplay]; +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end diff --git "a/DesignPatternsTests/Observe\350\247\202\345\257\237\350\200\205/Observe.m" "b/DesignPatternsTests/Observe\350\247\202\345\257\237\350\200\205/Observe.m" new file mode 100644 index 0000000..56e576f --- /dev/null +++ "b/DesignPatternsTests/Observe\350\247\202\345\257\237\350\200\205/Observe.m" @@ -0,0 +1,46 @@ +// +// Observe.m +// DesignPatterns +// +// Created by RenPeng on 16/8/23. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "ConcreteSubject.h" +#import "ConcreteObserver.h" +@interface Observe : XCTestCase + +@end + +@implementation Observe + +- (void)setUp { + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + + ConcreteSubject *subject = [[ConcreteSubject alloc] init]; + [subject attach:[[ConcreteObserver alloc] initConcreteObserver:subject name:@"X"]]; + [subject attach:[[ConcreteObserver alloc] initConcreteObserver:subject name:@"Y"]]; + [subject attach:[[ConcreteObserver alloc] initConcreteObserver:subject name:@"Z"]]; + + subject.subjectState = @"ABC"; + [subject notify]; +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end diff --git "a/DesignPatternsTests/Visitor\350\256\277\351\227\256\350\200\205/Visitor.m" "b/DesignPatternsTests/Visitor\350\256\277\351\227\256\350\200\205/Visitor.m" new file mode 100644 index 0000000..6b6ead1 --- /dev/null +++ "b/DesignPatternsTests/Visitor\350\256\277\351\227\256\350\200\205/Visitor.m" @@ -0,0 +1,56 @@ +// +// Visitor.m +// DesignPatterns +// +// Created by RenPeng on 16/8/31. +// Copyright © 2016年 leichunfeng. All rights reserved. +// + +#import +#import "ObjectStructure.h" +#import "Man.h" +#import "Woman.h" +#import "Success.h" +#import "Failing.h" +#import "Amativeness.h" + +@interface Visitor : XCTestCase + +@end + +@implementation Visitor + +- (void)setUp { + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + + ObjectStructure *o = [[ObjectStructure alloc] init]; + [o attach:[[Man alloc] init]]; + [o attach:[[Woman alloc] init]]; + + Success *v1 = [[Success alloc] init]; + [o display:v1]; + + Failing *v2 = [[Failing alloc] init]; + [o display:v2]; + + Amativeness *v3 = [[Amativeness alloc] init]; + [o display:v3]; +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end