├── .gitignore ├── src ├── Facade │ ├── UML.png │ └── HomeTheater │ │ ├── runHomeTheaterTestDrive.php │ │ ├── Screen.php │ │ ├── PopcornPopper.php │ │ └── TheaterLights.php ├── Adapter │ ├── UML.png │ └── Ducks │ │ ├── Duck.php │ │ ├── Turkey.php │ │ ├── turkey-index.php │ │ ├── MallardDuck.php │ │ └── WildTurkey.php ├── Command │ ├── UML.png │ ├── RemoteControl │ │ ├── UML.png │ │ ├── Command.php │ │ └── NoCommand.php │ ├── SimpleControl │ │ ├── Command.php │ │ ├── Light.php │ │ └── SimpleRemoteControl.php │ ├── Party │ │ ├── Command.php │ │ └── NoCommand.php │ └── UndoRemoteControl │ │ ├── Command.php │ │ └── NoCommand.php ├── Iterator │ ├── UML.png │ └── UML1.png ├── Decorator │ ├── UML.png │ ├── Example1 │ │ ├── UML.png │ │ ├── Beverage.php │ │ └── Beverage │ │ │ ├── Espresso.php │ │ │ ├── DarkRoast.php │ │ │ └── HouseBlend.php │ └── Example2 │ │ └── Beverage │ │ ├── Espresso.php │ │ ├── DarkRoast.php │ │ └── HouseBlend.php ├── TemplateMethod │ ├── UML.png │ ├── SimpleBarista │ │ ├── runBarista.php │ │ ├── Barista.php │ │ ├── Java │ │ │ ├── Barista.java │ │ │ ├── Tea.java │ │ │ └── Coffee.java │ │ ├── Tea.php │ │ └── Coffee.php │ └── Barista │ │ ├── runBeverageTestDrive.php │ │ ├── Tea.php │ │ ├── Coffee.php │ │ ├── Java │ │ ├── Tea.java │ │ ├── Coffee.java │ │ ├── CaffeineBeverage.java │ │ └── CaffeineBeverageWithHook.java │ │ ├── CaffeineBeverage.php │ │ ├── BeverageTestDrive.php │ │ └── CaffeineBeverageWithHook.php ├── Observer │ └── Example1 │ │ ├── UML.png │ │ ├── observer.png │ │ ├── DisplayElement.php │ │ ├── Observer.php │ │ └── Subject.php ├── Strategy │ ├── Example1 │ │ ├── uml.jpg │ │ ├── FlyBehavior │ │ │ ├── FlyBehavior.php │ │ │ ├── FlyNoWay.php │ │ │ ├── FlyWithWings.php │ │ │ └── FlyRocketPowered.php │ │ └── QuackBehavior │ │ │ ├── QuackBehavior.php │ │ │ ├── Quack.php │ │ │ ├── Squeak.php │ │ │ └── MuteQuack.php │ └── Example2 │ │ ├── TaxCalculationException.php │ │ └── TaxStrategy │ │ └── TaxStrategyPriorityInterface.php └── Factory │ ├── PizzaFactoryMethod │ ├── UML.png │ └── CreatePizzaException.php │ ├── PizzaSimpleFactory │ ├── UML.png │ ├── CreatePizzaException.php │ └── index.php │ └── PizzaAbstractFactory │ ├── Ingredient │ ├── Dough.php │ ├── Sauce.php │ ├── Clams.php │ ├── Cheese.php │ ├── Pepperoni.php │ ├── Vegetable.php │ ├── Clam │ │ └── FreshClams.php │ ├── Sauce │ │ └── MarinaraSauce.php │ ├── Vegetable │ │ ├── Garlic.php │ │ ├── Onion.php │ │ ├── Mushroom.php │ │ └── RedPepper.php │ ├── Dough │ │ └── ThinCrustDough.php │ ├── Cheese │ │ └── ReggianoCheese.php │ └── Pepperoni │ │ └── SlicedPepperoni.php │ └── CreatePizzaException.php ├── weburg ├── headfirst │ ├── factory │ │ └── pizzaaf │ │ │ ├── Clams.php │ │ │ ├── Dough.php │ │ │ ├── Sauce.php │ │ │ ├── Cheese.php │ │ │ ├── Veggies.php │ │ │ ├── Pepperoni.php │ │ │ ├── runPizzaTestDrive.php │ │ │ ├── Onion.php │ │ │ ├── Garlic.php │ │ │ ├── Spinach.php │ │ │ ├── Eggplant.php │ │ │ ├── Mushroom.php │ │ │ ├── RedPepper.php │ │ │ ├── BlackOlives.php │ │ │ ├── MarinaraSauce.php │ │ │ ├── ParmesanCheese.php │ │ │ ├── ReggianoCheese.php │ │ │ ├── ThinCrustDough.php │ │ │ ├── MozzarellaCheese.php │ │ │ ├── SlicedPepperoni.php │ │ │ ├── FreshClams.php │ │ │ ├── FrozenClams.php │ │ │ ├── PlumTomatoSauce.php │ │ │ ├── ThickCrustDough.php │ │ │ ├── PizzaIngredientFactory.php │ │ │ ├── PizzaStore.php │ │ │ ├── CheesePizza.php │ │ │ └── ClamPizza.php │ ├── combining │ │ ├── adapter │ │ │ ├── Quackable.php │ │ │ ├── Goose.php │ │ │ ├── runDuckSimulator.php │ │ │ ├── DuckCall.php │ │ │ ├── MallardDuck.php │ │ │ ├── RedheadDuck.php │ │ │ ├── RubberDuck.php │ │ │ ├── DecoyDuck.php │ │ │ └── GooseAdapter.php │ │ ├── ducks │ │ │ ├── Quackable.php │ │ │ ├── runDuckSimulator.php │ │ │ ├── DuckCall.php │ │ │ ├── MallardDuck.php │ │ │ ├── RedheadDuck.php │ │ │ ├── RubberDuck.php │ │ │ └── DecoyDuck.php │ │ ├── factory │ │ │ ├── Quackable.php │ │ │ ├── runDuckSimulator.php │ │ │ ├── RedheadDuck.php │ │ │ ├── Goose.php │ │ │ ├── DuckCall.php │ │ │ ├── RubberDuck.php │ │ │ ├── DecoyDuck.php │ │ │ ├── MallardDuck.php │ │ │ ├── AbstractDuckFactory.php │ │ │ ├── GooseAdapter.php │ │ │ ├── DuckFactory.php │ │ │ ├── CountingDuckFactory.php │ │ │ └── QuackCounter.php │ │ ├── composite │ │ │ ├── Quackable.php │ │ │ ├── runDuckSimulator.php │ │ │ ├── Goose.php │ │ │ ├── DuckCall.php │ │ │ ├── DecoyDuck.php │ │ │ ├── MallardDuck.php │ │ │ ├── RedheadDuck.php │ │ │ ├── RubberDuck.php │ │ │ ├── AbstractDuckFactory.php │ │ │ ├── GooseAdapter.php │ │ │ ├── DuckFactory.php │ │ │ ├── CountingDuckFactory.php │ │ │ ├── QuackCounter.php │ │ │ └── Flock.php │ │ ├── decorator │ │ │ ├── Quackable.php │ │ │ ├── runDuckSimulator.php │ │ │ ├── RedheadDuck.php │ │ │ ├── Goose.php │ │ │ ├── DuckCall.php │ │ │ ├── DecoyDuck.php │ │ │ ├── MallardDuck.php │ │ │ ├── RubberDuck.php │ │ │ ├── GooseAdapter.php │ │ │ └── QuackCounter.php │ │ └── observer │ │ │ ├── Observer.php │ │ │ ├── Quackable.php │ │ │ ├── runDuckSimulator.php │ │ │ ├── QuackObservable.php │ │ │ ├── Goose.php │ │ │ ├── AbstractDuckFactory.php │ │ │ ├── Quackologist.php │ │ │ ├── DuckFactory.php │ │ │ ├── CountingDuckFactory.php │ │ │ ├── DuckCall.php │ │ │ ├── RedheadDuck.php │ │ │ ├── RubberDuck.php │ │ │ ├── DecoyDuck.php │ │ │ └── MallardDuck.php │ ├── iterator │ │ ├── transition │ │ │ └── Menu.php │ │ ├── dinermerger │ │ │ ├── Menu.php │ │ │ ├── My2Iterator.php │ │ │ ├── runMenuTestDrive.php │ │ │ ├── ArrayIterator.php │ │ │ ├── ArrayListIterator.php │ │ │ └── PancakeHouseMenuIterator.php │ │ ├── dinermergercafe │ │ │ ├── Menu.php │ │ │ └── runMenuTestDrive.php │ │ └── dinermergeri │ │ │ ├── Menu.php │ │ │ └── runMenuTestDrive.php │ ├── composite │ │ ├── menu │ │ │ ├── runMenuTestDrive.php │ │ │ └── Waitress.php │ │ └── menuiterator │ │ │ ├── runMenuTestDrive.php │ │ │ └── NullIterator.php │ ├── singleton │ │ ├── stat │ │ │ ├── runSingletonClient.php │ │ │ ├── SingletonClient.php │ │ │ └── Singleton.php │ │ ├── chocolate │ │ │ ├── runChocolateController.php │ │ │ └── ChocolateController.php │ │ ├── subclass │ │ │ ├── runSingletonTestDrive.php │ │ │ ├── HotterSingleton.php │ │ │ ├── SingletonTestDrive.php │ │ │ └── CoolerSingleton.php │ │ └── classic │ │ │ └── runSingleton.php │ ├── proxy │ │ ├── javaproxy │ │ │ ├── runMatchMakingTestDrive.php │ │ │ └── PersonBean.php │ │ ├── gumball │ │ │ ├── runGumballMachineTestDrive.php │ │ │ ├── runGumballMonitorTestDrive.php │ │ │ ├── GumballMachineRemote.php │ │ │ ├── State.php │ │ │ ├── stopGumballMachineTestDrive.php │ │ │ ├── GumballMachineTestDrive.php │ │ │ ├── GumballMonitorTestDrive.php │ │ │ └── GumballMonitor.php │ │ └── gumballmonitor │ │ │ ├── runGumballMachineTestDrive.php │ │ │ ├── State.php │ │ │ └── GumballMonitor.php │ ├── state │ │ ├── gumball │ │ │ └── runGumballMachineTestDrive.php │ │ ├── gumballstate │ │ │ ├── runGumballMachineTestDrive.php │ │ │ ├── State.php │ │ │ └── GumballMachineTestDrive.php │ │ └── gumballstatewinner │ │ │ ├── runGumballMachineTestDrive.php │ │ │ └── State.php │ └── combined │ │ └── djviewweb │ │ ├── application │ │ ├── models │ │ │ ├── BeatModelInterface.php │ │ │ └── BeatModel.php │ │ └── bootstrap.php │ │ └── public │ │ └── index.php └── library │ ├── custom │ └── mvc │ │ └── Model.php │ └── java │ ├── InvocationHandler.php │ ├── Comparable.php │ ├── MyEnumeration.php │ ├── MyIterator.php │ └── Proxy.php ├── documentation ├── 12-composite.md ├── 13-state.md ├── 9-facade.md ├── 8-adapter.md ├── 10-template-method.md └── 7-command.md ├── java-design-pattern └── Head-First-Design-Patterns-master │ ├── test.txt │ ├── src │ └── headfirst │ │ └── designpatterns │ │ ├── strategy │ │ ├── FlyBehavior.java │ │ ├── QuackBehavior.java │ │ ├── Quack.java │ │ ├── Squeak.java │ │ ├── FakeQuack.java │ │ ├── FlyNoWay.java │ │ ├── FlyWithWings.java │ │ ├── MuteQuack.java │ │ ├── FlyRocketPowered.java │ │ ├── DecoyDuck.java │ │ ├── ModelDuck.java │ │ ├── RubberDuck.java │ │ ├── RedHeadDuck.java │ │ ├── MallardDuck.java │ │ ├── MiniDuckSimulator1.java │ │ └── MiniDuckSimulator.java │ │ ├── ducks │ │ ├── Duck.java │ │ ├── Turkey.java │ │ ├── MallardDuck.java │ │ ├── WildTurkey.java │ │ ├── TurkeyAdapter.java │ │ ├── TurkeyTestDrive.java │ │ └── DuckAdapter.java │ │ ├── combining │ │ ├── ducks │ │ │ ├── Quackable.java │ │ │ ├── DuckCall.java │ │ │ ├── MallardDuck.java │ │ │ ├── RedheadDuck.java │ │ │ ├── RubberDuck.java │ │ │ └── DecoyDuck.java │ │ ├── adapter │ │ │ ├── Quackable.java │ │ │ ├── Goose.java │ │ │ ├── DuckCall.java │ │ │ ├── MallardDuck.java │ │ │ ├── RedheadDuck.java │ │ │ ├── RubberDuck.java │ │ │ ├── DecoyDuck.java │ │ │ └── GooseAdapter.java │ │ ├── factory │ │ │ ├── Quackable.java │ │ │ ├── RedheadDuck.java │ │ │ ├── Goose.java │ │ │ ├── DuckCall.java │ │ │ ├── MallardDuck.java │ │ │ ├── RubberDuck.java │ │ │ ├── DecoyDuck.java │ │ │ ├── AbstractDuckFactory.java │ │ │ ├── GooseAdapter.java │ │ │ ├── DuckFactory.java │ │ │ ├── QuackCounter.java │ │ │ └── CountingDuckFactory.java │ │ ├── composite │ │ │ ├── Quackable.java │ │ │ ├── Goose.java │ │ │ ├── DuckCall.java │ │ │ ├── RedheadDuck.java │ │ │ ├── MallardDuck.java │ │ │ ├── RubberDuck.java │ │ │ ├── DecoyDuck.java │ │ │ ├── AbstractDuckFactory.java │ │ │ ├── GooseAdapter.java │ │ │ ├── DuckFactory.java │ │ │ ├── QuackCounter.java │ │ │ └── CountingDuckFactory.java │ │ ├── decorator │ │ │ ├── Quackable.java │ │ │ ├── RedheadDuck.java │ │ │ ├── Goose.java │ │ │ ├── DuckCall.java │ │ │ ├── MallardDuck.java │ │ │ ├── RubberDuck.java │ │ │ ├── DecoyDuck.java │ │ │ ├── GooseAdapter.java │ │ │ └── QuackCounter.java │ │ └── observer │ │ │ ├── Observer.java │ │ │ ├── Quackable.java │ │ │ ├── QuackObservable.java │ │ │ ├── .QuackDecorator.java.swp │ │ │ ├── Goose.java │ │ │ ├── Quackologist.java │ │ │ ├── AbstractDuckFactory.java │ │ │ ├── DuckFactory.java │ │ │ ├── CountingDuckFactory.java │ │ │ ├── DuckCall.java │ │ │ ├── RedheadDuck.java │ │ │ └── RubberDuck.java │ │ ├── factory │ │ ├── pizzaaf │ │ │ ├── Cheese.java │ │ │ ├── Clams.java │ │ │ ├── Dough.java │ │ │ ├── Sauce.java │ │ │ ├── Veggies.java │ │ │ ├── Pepperoni.java │ │ │ ├── Garlic.java │ │ │ ├── Onion.java │ │ │ ├── Eggplant.java │ │ │ ├── Spinach.java │ │ │ ├── Mushroom.java │ │ │ ├── RedPepper.java │ │ │ ├── BlackOlives.java │ │ │ ├── MarinaraSauce.java │ │ │ ├── ThinCrustDough.java │ │ │ ├── ParmesanCheese.java │ │ │ ├── ReggianoCheese.java │ │ │ ├── SlicedPepperoni.java │ │ │ ├── FreshClams.java │ │ │ ├── FrozenClams.java │ │ │ ├── MozzarellaCheese.java │ │ │ ├── PlumTomatoSauce.java │ │ │ ├── ThickCrustDough.java │ │ │ ├── PizzaIngredientFactory.java │ │ │ ├── PizzaStore.java │ │ │ ├── CheesePizza.java │ │ │ ├── ClamPizza.java │ │ │ └── VeggiePizza.java │ │ ├── pizzas │ │ │ ├── ClamPizza.java │ │ │ ├── CheesePizza.java │ │ │ ├── PepperoniPizza.java │ │ │ ├── PizzaStore.java │ │ │ ├── VeggiePizza.java │ │ │ ├── SimplePizzaFactory.java │ │ │ └── PizzaTestDrive.java │ │ └── pizzafm │ │ │ ├── NYStyleCheesePizza.java │ │ │ ├── NYStyleClamPizza.java │ │ │ ├── PizzaStore.java │ │ │ ├── NYStyleVeggiePizza.java │ │ │ ├── ChicagoStyleCheesePizza.java │ │ │ ├── ChicagoStyleClamPizza.java │ │ │ ├── NYStylePepperoniPizza.java │ │ │ ├── NYPizzaStore.java │ │ │ ├── ChicagoStyleVeggiePizza.java │ │ │ └── ChicagoStylePepperoniPizza.java │ │ ├── combined │ │ └── djview │ │ │ ├── BPMObserver.java │ │ │ ├── BeatObserver.java │ │ │ ├── jsp │ │ │ └── index.html │ │ │ ├── ControllerInterface.java │ │ │ ├── DJTestDrive.java │ │ │ ├── HeartTestDrive.java │ │ │ ├── HeartModelInterface.java │ │ │ └── BeatModelInterface.java │ │ ├── collections │ │ ├── iterator │ │ │ ├── Menu.java │ │ │ ├── Iterator.java │ │ │ └── DinerMenuIterator.java │ │ └── iterator_builtin │ │ │ └── Menu.java │ │ ├── iterator │ │ ├── dinermerger │ │ │ ├── Menu.java │ │ │ ├── Iterator.java │ │ │ ├── ArrayIterator.java │ │ │ └── DinerMenuIterator.java │ │ ├── transition │ │ │ ├── Menu.java │ │ │ └── MenuTestDrive.java │ │ ├── dinermergeri │ │ │ └── Menu.java │ │ └── dinermergercafe │ │ │ └── Menu.java │ │ ├── observer │ │ ├── weather │ │ │ ├── DisplayElement.java │ │ │ ├── Observer.java │ │ │ └── Subject.java │ │ └── weatherobservable │ │ │ └── DisplayElement.java │ │ ├── decorator │ │ ├── starbuzz │ │ │ ├── CondimentDecorator.java │ │ │ ├── Decaf.java │ │ │ ├── DarkRoast.java │ │ │ ├── Espresso.java │ │ │ ├── HouseBlend.java │ │ │ ├── Beverage.java │ │ │ ├── Soy.java │ │ │ ├── Milk.java │ │ │ ├── Mocha.java │ │ │ └── Whip.java │ │ ├── starbuzzWithSizes │ │ │ ├── Decaf.java │ │ │ ├── Espresso.java │ │ │ ├── DarkRoast.java │ │ │ ├── HouseBlend.java │ │ │ ├── CondimentDecorator.java │ │ │ ├── Milk.java │ │ │ ├── Whip.java │ │ │ ├── Mocha.java │ │ │ └── Beverage.java │ │ └── io │ │ │ └── InputTest.java │ │ ├── singleton │ │ ├── dcl │ │ │ ├── SingletonClient.java │ │ │ └── Singleton.java │ │ ├── stat │ │ │ ├── SingletonClient.java │ │ │ └── Singleton.java │ │ ├── classic │ │ │ ├── SingletonClient.java │ │ │ └── Singleton.java │ │ ├── subclass │ │ │ ├── HotterSingleton.java │ │ │ ├── CoolerSingleton.java │ │ │ ├── SingletonTestDrive.java │ │ │ └── Singleton.java │ │ ├── threadsafe │ │ │ ├── SingletonClient.java │ │ │ └── Singleton.java │ │ └── chocolate │ │ │ └── ChocolateController.java │ │ ├── proxy │ │ ├── gumball │ │ │ ├── State.java │ │ │ ├── GumballMachineRemote.java │ │ │ └── README.md │ │ ├── gumballmonitor │ │ │ ├── State.java │ │ │ └── GumballMonitor.java │ │ └── javaproxy │ │ │ └── PersonBean.java │ │ ├── state │ │ ├── gumballstate │ │ │ └── State.java │ │ └── gumballstatewinner │ │ │ └── State.java │ │ ├── composite │ │ ├── menu │ │ │ └── Waitress.java │ │ └── menuiterator │ │ │ └── NullIterator.java │ │ └── iterenum │ │ ├── EnumerationIteratorTestDrive.java │ │ ├── IteratorEnumerationTestDrive.java │ │ ├── IteratorEnumeration.java │ │ └── EnumerationIterator.java │ ├── README.md │ └── heatindex.txt └── composer.json /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/ 2 | /.idea/ 3 | -------------------------------------------------------------------------------- /src/Facade/UML.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TBlindaruk/head-first-design-pattern/HEAD/src/Facade/UML.png -------------------------------------------------------------------------------- /src/Adapter/UML.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TBlindaruk/head-first-design-pattern/HEAD/src/Adapter/UML.png -------------------------------------------------------------------------------- /src/Command/UML.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TBlindaruk/head-first-design-pattern/HEAD/src/Command/UML.png -------------------------------------------------------------------------------- /src/Iterator/UML.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TBlindaruk/head-first-design-pattern/HEAD/src/Iterator/UML.png -------------------------------------------------------------------------------- /src/Decorator/UML.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TBlindaruk/head-first-design-pattern/HEAD/src/Decorator/UML.png -------------------------------------------------------------------------------- /src/Iterator/UML1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TBlindaruk/head-first-design-pattern/HEAD/src/Iterator/UML1.png -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/Clams.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/Dough.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/Sauce.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/adapter/Quackable.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/ducks/Quackable.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/factory/Quackable.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/Cheese.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/Veggies.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/iterator/transition/Menu.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/TemplateMethod/UML.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TBlindaruk/head-first-design-pattern/HEAD/src/TemplateMethod/UML.png -------------------------------------------------------------------------------- /weburg/headfirst/combining/composite/Quackable.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/decorator/Quackable.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/Pepperoni.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/iterator/dinermerger/Menu.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/iterator/dinermergercafe/Menu.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/iterator/dinermergeri/Menu.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /documentation/12-composite.md: -------------------------------------------------------------------------------- 1 | ## Composite 2 | 3 | ### TODO: 4 | - [ ] add from 409 page 5 | - [ ] add UML 6 | - [ ] add examples -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/test.txt: -------------------------------------------------------------------------------- 1 | I know the Decorator Pattern and HOW it's used in the JAVA.IO package. -------------------------------------------------------------------------------- /src/Decorator/Example1/UML.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TBlindaruk/head-first-design-pattern/HEAD/src/Decorator/Example1/UML.png -------------------------------------------------------------------------------- /src/Observer/Example1/UML.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TBlindaruk/head-first-design-pattern/HEAD/src/Observer/Example1/UML.png -------------------------------------------------------------------------------- /src/Strategy/Example1/uml.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TBlindaruk/head-first-design-pattern/HEAD/src/Strategy/Example1/uml.jpg -------------------------------------------------------------------------------- /src/Command/RemoteControl/UML.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TBlindaruk/head-first-design-pattern/HEAD/src/Command/RemoteControl/UML.png -------------------------------------------------------------------------------- /src/Observer/Example1/observer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TBlindaruk/head-first-design-pattern/HEAD/src/Observer/Example1/observer.png -------------------------------------------------------------------------------- /weburg/headfirst/combining/adapter/Goose.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/observer/Observer.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/library/custom/mvc/Model.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/Factory/PizzaFactoryMethod/UML.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TBlindaruk/head-first-design-pattern/HEAD/src/Factory/PizzaFactoryMethod/UML.png -------------------------------------------------------------------------------- /src/Factory/PizzaSimpleFactory/UML.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TBlindaruk/head-first-design-pattern/HEAD/src/Factory/PizzaSimpleFactory/UML.png -------------------------------------------------------------------------------- /src/TemplateMethod/SimpleBarista/runBarista.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/observer/Quackable.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/TemplateMethod/Barista/runBeverageTestDrive.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/adapter/runDuckSimulator.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/ducks/runDuckSimulator.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/factory/runDuckSimulator.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/composite/menu/runMenuTestDrive.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/runPizzaTestDrive.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/composite/runDuckSimulator.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/decorator/runDuckSimulator.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/observer/runDuckSimulator.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/composite/menuiterator/runMenuTestDrive.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/Onion.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/iterator/dinermerger/My2Iterator.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/iterator/dinermerger/runMenuTestDrive.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/iterator/dinermergeri/runMenuTestDrive.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/singleton/stat/runSingletonClient.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/library/java/InvocationHandler.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/adapter/DuckCall.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/ducks/DuckCall.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/Garlic.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/Spinach.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/iterator/dinermergercafe/runMenuTestDrive.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/ducks/MallardDuck.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/ducks/RedheadDuck.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/ducks/RubberDuck.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/Eggplant.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/Mushroom.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/proxy/javaproxy/runMatchMakingTestDrive.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/singleton/chocolate/runChocolateController.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/singleton/subclass/runSingletonTestDrive.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/adapter/MallardDuck.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/adapter/RedheadDuck.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/adapter/RubberDuck.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/decorator/RedheadDuck.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/ducks/DecoyDuck.php: -------------------------------------------------------------------------------- 1 | >"); 5 | } 6 | } 7 | ?> -------------------------------------------------------------------------------- /weburg/headfirst/combining/factory/RedheadDuck.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/RedPepper.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/proxy/gumball/runGumballMachineTestDrive.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/proxy/gumball/runGumballMonitorTestDrive.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/state/gumball/runGumballMachineTestDrive.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/adapter/DecoyDuck.php: -------------------------------------------------------------------------------- 1 | >"); 5 | } 6 | } 7 | ?> -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/BlackOlives.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/proxy/gumballmonitor/runGumballMachineTestDrive.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/state/gumballstate/runGumballMachineTestDrive.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/MarinaraSauce.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/state/gumballstatewinner/runGumballMachineTestDrive.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/library/java/Comparable.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /documentation/13-state.md: -------------------------------------------------------------------------------- 1 | ## State 2 | 3 | ### TODO: 4 | - [ ] додати визначення 5 | - [ ] додати абстракту UML діаграму 6 | - [ ] додати не абстракту UML діаграму 7 | - [ ] додати приклади -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/ParmesanCheese.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/ReggianoCheese.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/ThinCrustDough.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/MozzarellaCheese.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/SlicedPepperoni.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/FreshClams.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/FrozenClams.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/observer/QuackObservable.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/PlumTomatoSauce.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/singleton/stat/SingletonClient.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/proxy/gumball/GumballMachineRemote.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/ThickCrustDough.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/factory/Goose.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/observer/Goose.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/proxy/gumball/State.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/library/java/MyEnumeration.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/strategy/FlyBehavior.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.strategy; 2 | 3 | public interface FlyBehavior { 4 | public void fly(); 5 | } 6 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/composite/Goose.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/decorator/Goose.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/state/gumballstate/State.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/ducks/Duck.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.ducks; 2 | 3 | public interface Duck { 4 | public void quack(); 5 | public void fly(); 6 | } 7 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/strategy/QuackBehavior.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.strategy; 2 | 3 | public interface QuackBehavior { 4 | public void quack(); 5 | } 6 | -------------------------------------------------------------------------------- /weburg/headfirst/proxy/gumballmonitor/State.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/state/gumballstatewinner/State.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/ducks/Quackable.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.ducks; 2 | 3 | public interface Quackable { 4 | public void quack(); 5 | } 6 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/ducks/Turkey.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.ducks; 2 | 3 | public interface Turkey { 4 | public void gobble(); 5 | public void fly(); 6 | } 7 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/Cheese.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public interface Cheese { 4 | public String toString(); 5 | } 6 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/Clams.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public interface Clams { 4 | public String toString(); 5 | } 6 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/Dough.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public interface Dough { 4 | public String toString(); 5 | } 6 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/Sauce.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public interface Sauce { 4 | public String toString(); 5 | } 6 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/Veggies.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public interface Veggies { 4 | public String toString(); 5 | } 6 | -------------------------------------------------------------------------------- /weburg/library/java/MyIterator.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combined/djview/BPMObserver.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combined.djview; 2 | 3 | public interface BPMObserver { 4 | void updateBPM(); 5 | } 6 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combined/djview/BeatObserver.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combined.djview; 2 | 3 | public interface BeatObserver { 4 | void updateBeat(); 5 | } 6 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/adapter/Quackable.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.adapter; 2 | 3 | public interface Quackable { 4 | public void quack(); 5 | } 6 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/factory/Quackable.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.factory; 2 | 3 | public interface Quackable { 4 | public void quack(); 5 | } 6 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/Pepperoni.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public interface Pepperoni { 4 | public String toString(); 5 | } 6 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/composite/Quackable.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.composite; 2 | 3 | public interface Quackable { 4 | public void quack(); 5 | } 6 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/decorator/Quackable.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.decorator; 2 | 3 | public interface Quackable { 4 | public void quack(); 5 | } 6 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/collections/iterator/Menu.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.collections.iterator; 2 | 3 | public interface Menu { 4 | public Iterator createIterator(); 5 | } 6 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/iterator/dinermerger/Menu.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.iterator.dinermerger; 2 | 3 | public interface Menu { 4 | public Iterator createIterator(); 5 | } 6 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/observer/weather/DisplayElement.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.observer.weather; 2 | 3 | public interface DisplayElement { 4 | public void display(); 5 | } 6 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/composite/DuckCall.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/decorator/DuckCall.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/factory/DuckCall.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/collections/iterator/Iterator.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.collections.iterator; 2 | 3 | public interface Iterator { 4 | boolean hasNext(); 5 | Object next(); 6 | } 7 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/observer/Observer.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.observer; 2 | 3 | public interface Observer { 4 | public void update(QuackObservable duck); 5 | } 6 | -------------------------------------------------------------------------------- /src/TemplateMethod/Barista/Tea.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/factory/RubberDuck.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/observer/Quackable.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.observer; 2 | 3 | public interface Quackable extends QuackObservable { 4 | public void quack(); 5 | } 6 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/iterator/dinermerger/Iterator.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.iterator.dinermerger; 2 | 3 | public interface Iterator { 4 | boolean hasNext(); 5 | MenuItem next(); 6 | } 7 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/composite/DecoyDuck.php: -------------------------------------------------------------------------------- 1 | >"); 5 | } 6 | 7 | public function __toString() { 8 | return "Decoy Duck"; 9 | } 10 | } 11 | ?> -------------------------------------------------------------------------------- /weburg/headfirst/combining/composite/MallardDuck.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/composite/RedheadDuck.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/composite/RubberDuck.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/decorator/DecoyDuck.php: -------------------------------------------------------------------------------- 1 | >"); 5 | } 6 | 7 | public function __toString() { 8 | return "Decoy Duck"; 9 | } 10 | } 11 | ?> -------------------------------------------------------------------------------- /weburg/headfirst/combining/decorator/MallardDuck.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/decorator/RubberDuck.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/factory/DecoyDuck.php: -------------------------------------------------------------------------------- 1 | >"); 5 | } 6 | 7 | public function __toString() { 8 | return "Decoy Duck"; 9 | } 10 | } 11 | ?> -------------------------------------------------------------------------------- /weburg/headfirst/combining/factory/MallardDuck.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/adapter/Goose.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.adapter; 2 | 3 | public class Goose { 4 | public void honk() { 5 | System.out.println("Honk"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/observer/weatherobservable/DisplayElement.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.observer.weatherobservable; 2 | 3 | public interface DisplayElement { 4 | public void display(); 5 | } 6 | -------------------------------------------------------------------------------- /src/Facade/HomeTheater/runHomeTheaterTestDrive.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combined/djviewweb/application/models/BeatModelInterface.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/observer/weather/Observer.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.observer.weather; 2 | 3 | public interface Observer { 4 | public void update(float temp, float humidity, float pressure); 5 | } 6 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/strategy/Quack.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.strategy; 2 | 3 | public class Quack implements QuackBehavior { 4 | public void quack() { 5 | System.out.println("Quack"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/strategy/Squeak.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.strategy; 2 | 3 | public class Squeak implements QuackBehavior { 4 | public void quack() { 5 | System.out.println("Squeak"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/TemplateMethod/Barista/Coffee.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/singleton/subclass/HotterSingleton.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/Garlic.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public class Garlic implements Veggies { 4 | 5 | public String toString() { 6 | return "Garlic"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/Onion.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public class Onion implements Veggies { 4 | 5 | public String toString() { 6 | return "Onion"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/iterator/transition/Menu.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.iterator.transition; 2 | 3 | import java.util.Iterator; 4 | 5 | public interface Menu { 6 | public Iterator createIterator(); 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/strategy/FakeQuack.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.strategy; 2 | 3 | public class FakeQuack implements QuackBehavior { 4 | public void quack() { 5 | System.out.println("Qwak"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/strategy/FlyNoWay.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.strategy; 2 | 3 | public class FlyNoWay implements FlyBehavior { 4 | public void fly() { 5 | System.out.println("I can't fly"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/Eggplant.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public class Eggplant implements Veggies { 4 | 5 | public String toString() { 6 | return "Eggplant"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/Spinach.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public class Spinach implements Veggies { 4 | 5 | public String toString() { 6 | return "Spinach"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/adapter/DuckCall.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.adapter; 2 | 3 | public class DuckCall implements Quackable { 4 | public void quack() { 5 | System.out.println("Kwak"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/ducks/DuckCall.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.ducks; 2 | 3 | public class DuckCall implements Quackable { 4 | public void quack() { 5 | System.out.println("Kwak"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/Mushroom.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public class Mushroom implements Veggies { 4 | 5 | public String toString() { 6 | return "Mushrooms"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/RedPepper.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public class RedPepper implements Veggies { 4 | 5 | public String toString() { 6 | return "Red Pepper"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/iterator/dinermergeri/Menu.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.iterator.dinermergeri; 2 | 3 | import java.util.Iterator; 4 | 5 | public interface Menu { 6 | public Iterator createIterator(); 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/strategy/FlyWithWings.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.strategy; 2 | 3 | public class FlyWithWings implements FlyBehavior { 4 | public void fly() { 5 | System.out.println("I'm flying!!"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/strategy/MuteQuack.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.strategy; 2 | 3 | public class MuteQuack implements QuackBehavior { 4 | public void quack() { 5 | System.out.println("<< Silence >>"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/ducks/MallardDuck.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.ducks; 2 | 3 | public class MallardDuck implements Quackable { 4 | public void quack() { 5 | System.out.println("Quack"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/ducks/RedheadDuck.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.ducks; 2 | 3 | public class RedheadDuck implements Quackable { 4 | public void quack() { 5 | System.out.println("Quack"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/ducks/RubberDuck.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.ducks; 2 | 3 | public class RubberDuck implements Quackable { 4 | public void quack() { 5 | System.out.println("Squeak"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/decorator/starbuzz/CondimentDecorator.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.decorator.starbuzz; 2 | 3 | public abstract class CondimentDecorator extends Beverage { 4 | public abstract String getDescription(); 5 | } 6 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/BlackOlives.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public class BlackOlives implements Veggies { 4 | 5 | public String toString() { 6 | return "Black Olives"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/MarinaraSauce.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public class MarinaraSauce implements Sauce { 4 | public String toString() { 5 | return "Marinara Sauce"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/adapter/MallardDuck.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.adapter; 2 | 3 | public class MallardDuck implements Quackable { 4 | public void quack() { 5 | System.out.println("Quack"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/adapter/RedheadDuck.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.adapter; 2 | 3 | public class RedheadDuck implements Quackable { 4 | public void quack() { 5 | System.out.println("Quack"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/adapter/RubberDuck.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.adapter; 2 | 3 | public class RubberDuck implements Quackable { 4 | public void quack() { 5 | System.out.println("Squeak"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/ducks/DecoyDuck.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.ducks; 2 | 3 | public class DecoyDuck implements Quackable { 4 | public void quack() { 5 | System.out.println("<< Silence >>"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/factory/RedheadDuck.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.factory; 2 | 3 | public class RedheadDuck implements Quackable { 4 | public void quack() { 5 | System.out.println("Quack"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/ThinCrustDough.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public class ThinCrustDough implements Dough { 4 | public String toString() { 5 | return "Thin Crust Dough"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/iterator/dinermergercafe/Menu.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.iterator.dinermergercafe; 2 | 3 | import java.util.Iterator; 4 | 5 | public interface Menu { 6 | public Iterator createIterator(); 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/collections/iterator_builtin/Menu.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.collections.iterator_builtin; 2 | 3 | import java.util.Iterator; 4 | 5 | public interface Menu { 6 | public Iterator createIterator(); 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/adapter/DecoyDuck.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.adapter; 2 | 3 | public class DecoyDuck implements Quackable { 4 | public void quack() { 5 | System.out.println("<< Silence >>"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/decorator/RedheadDuck.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.decorator; 2 | 3 | public class RedheadDuck implements Quackable { 4 | public void quack() { 5 | System.out.println("Quack"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/ParmesanCheese.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public class ParmesanCheese implements Cheese { 4 | 5 | public String toString() { 6 | return "Shredded Parmesan"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/ReggianoCheese.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public class ReggianoCheese implements Cheese { 4 | 5 | public String toString() { 6 | return "Reggiano Cheese"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /weburg/library/java/Proxy.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/SlicedPepperoni.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public class SlicedPepperoni implements Pepperoni { 4 | 5 | public String toString() { 6 | return "Sliced Pepperoni"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/strategy/FlyRocketPowered.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.strategy; 2 | 3 | public class FlyRocketPowered implements FlyBehavior { 4 | public void fly() { 5 | System.out.println("I'm flying with a rocket"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/factory/AbstractDuckFactory.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/observer/AbstractDuckFactory.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/proxy/gumball/stopGumballMachineTestDrive.php: -------------------------------------------------------------------------------- 1 | shutdown(); 11 | ?> -------------------------------------------------------------------------------- /weburg/headfirst/singleton/subclass/SingletonTestDrive.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/observer/QuackObservable.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.observer; 2 | 3 | public interface QuackObservable { 4 | public void registerObserver(Observer observer); 5 | public void notifyObservers(); 6 | } 7 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/FreshClams.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public class FreshClams implements Clams { 4 | 5 | public String toString() { 6 | return "Fresh Clams from Long Island Sound"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/FrozenClams.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public class FrozenClams implements Clams { 4 | 5 | public String toString() { 6 | return "Frozen Clams from Chesapeake Bay"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/MozzarellaCheese.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public class MozzarellaCheese implements Cheese { 4 | 5 | public String toString() { 6 | return "Shredded Mozzarella"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/PlumTomatoSauce.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public class PlumTomatoSauce implements Sauce { 4 | public String toString() { 5 | return "Tomato sauce with plum tomatoes"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/singleton/dcl/SingletonClient.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.singleton.dcl; 2 | 3 | public class SingletonClient { 4 | public static void main(String[] args) { 5 | Singleton singleton = Singleton.getInstance(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/composite/AbstractDuckFactory.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/observer/Quackologist.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/singleton/subclass/CoolerSingleton.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/observer/.QuackDecorator.java.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TBlindaruk/head-first-design-pattern/HEAD/java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/observer/.QuackDecorator.java.swp -------------------------------------------------------------------------------- /documentation/9-facade.md: -------------------------------------------------------------------------------- 1 | ## Facade 2 | 3 | Паттерн Фасад предоставляет унифицированый интерфейс к группе интерфейсов подсистемы. Фасад определяет высокоуровневый интерфейс, упрощающий работу с подсистемой. 4 | 5 | ![Facade](./../src/Facade/UML.png) 6 | 7 | ### TODO: 8 | - [ ]refactoring of Facade code example -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combined/djview/jsp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | DJView Web Application 6 | 7 | 8 | DJView 9 | 10 | 11 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/ThickCrustDough.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public class ThickCrustDough implements Dough { 4 | public String toString() { 5 | return "ThickCrust style extra thick crust dough"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/observer/weather/Subject.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.observer.weather; 2 | 3 | public interface Subject { 4 | public void registerObserver(Observer o); 5 | public void removeObserver(Observer o); 6 | public void notifyObservers(); 7 | } 8 | -------------------------------------------------------------------------------- /src/TemplateMethod/Barista/Java/Tea.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.templatemethod.barista; 2 | 3 | public class Tea extends CaffeineBeverage { 4 | public void brew() { 5 | System.out.println("Steeping the tea"); 6 | } 7 | public void addCondiments() { 8 | System.out.println("Adding Lemon"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/TemplateMethod/SimpleBarista/Barista.php: -------------------------------------------------------------------------------- 1 | prepareRecipe(); 8 | println("Making coffee..."); 9 | $coffee->prepareRecipe(); 10 | } 11 | } 12 | ?> -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/factory/Goose.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.factory; 2 | 3 | public class Goose { 4 | public void honk() { 5 | System.out.println("Honk"); 6 | } 7 | 8 | public String toString() { 9 | return "Goose"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/PizzaIngredientFactory.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/composite/Goose.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.composite; 2 | 3 | public class Goose { 4 | public void honk() { 5 | System.out.println("Honk"); 6 | } 7 | 8 | public String toString() { 9 | return "Goose"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/decorator/Goose.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.decorator; 2 | 3 | public class Goose { 4 | public void honk() { 5 | System.out.println("Honk"); 6 | } 7 | 8 | public String toString() { 9 | return "Goose"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combined/djview/ControllerInterface.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combined.djview; 2 | 3 | public interface ControllerInterface { 4 | void start(); 5 | void stop(); 6 | void increaseBPM(); 7 | void decreaseBPM(); 8 | void setBPM(int bpm); 9 | } 10 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/observer/Goose.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.observer; 2 | 3 | public class Goose { 4 | 5 | public void honk() { 6 | System.out.println("Honk"); 7 | } 8 | 9 | public String toString() { 10 | return "Goose"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Command/SimpleControl/Command.php: -------------------------------------------------------------------------------- 1 | allMenus = $allMenus; 10 | } 11 | 12 | public function printMenu() { 13 | $this->allMenus->myPrint(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Factory/PizzaAbstractFactory/Ingredient/Dough.php: -------------------------------------------------------------------------------- 1 | setControllerPath(APPLICATION_PATH . DIRECTORY_SEPARATOR . "controllers"); 7 | $dispatcher->setDefaultControllerName("DJView"); 8 | $dispatcher->dispatch(); 9 | ?> -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/decorator/starbuzz/DarkRoast.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.decorator.starbuzz; 2 | 3 | public class DarkRoast extends Beverage { 4 | public DarkRoast() { 5 | description = "Dark Roast Coffee"; 6 | } 7 | 8 | public double cost() { 9 | return .99; 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/decorator/starbuzz/Espresso.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.decorator.starbuzz; 2 | 3 | public class Espresso extends Beverage { 4 | 5 | public Espresso() { 6 | description = "Espresso"; 7 | } 8 | 9 | public double cost() { 10 | return 1.99; 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/decorator/starbuzzWithSizes/Decaf.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.decorator.starbuzzWithSizes; 2 | 3 | public class Decaf extends Beverage { 4 | public Decaf() { 5 | description = "Decaf Coffee"; 6 | } 7 | 8 | public double cost() { 9 | return 1.05; 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/singleton/classic/SingletonClient.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.singleton.classic; 2 | 3 | public class SingletonClient { 4 | public static void main(String[] args) { 5 | Singleton singleton = Singleton.getInstance(); 6 | System.out.println(singleton.getDescription()); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/Adapter/Ducks/Turkey.php: -------------------------------------------------------------------------------- 1 | Патерн Адаптер преобразует интерфейс класа к другому интерфейсу, на который расчитан клиент. Адаптер обеспечивает совместную работу классов, невозмоную в обычных условиях из-за несовместимости интерфейсов. 4 | 5 | ![Command](./../src/Adapter/UML.png) 6 | 7 | ### Example 8 | 9 | - [Ducks](./../src/Adapter/Ducks) 10 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/composite/DuckCall.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.composite; 2 | 3 | public class DuckCall implements Quackable { 4 | 5 | public void quack() { 6 | System.out.println("Kwak"); 7 | } 8 | 9 | public String toString() { 10 | return "Duck Call"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/decorator/DuckCall.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.decorator; 2 | 3 | public class DuckCall implements Quackable { 4 | 5 | public void quack() { 6 | System.out.println("Kwak"); 7 | } 8 | 9 | public String toString() { 10 | return "Duck Call"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/ducks/WildTurkey.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.ducks; 2 | 3 | public class WildTurkey implements Turkey { 4 | public void gobble() { 5 | System.out.println("Gobble gobble"); 6 | } 7 | 8 | public void fly() { 9 | System.out.println("I'm flying a short distance"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/singleton/subclass/HotterSingleton.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.singleton.subclass; 2 | 3 | public class HotterSingleton extends Singleton { 4 | // useful instance variables here 5 | 6 | private HotterSingleton() { 7 | super(); 8 | } 9 | 10 | // useful methods here 11 | } 12 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/singleton/threadsafe/SingletonClient.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.singleton.threadsafe; 2 | 3 | public class SingletonClient { 4 | public static void main(String[] args) { 5 | Singleton singleton = Singleton.getInstance(); 6 | System.out.println(singleton.getDescription()); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /weburg/headfirst/composite/menuiterator/NullIterator.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/composite/RedheadDuck.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.composite; 2 | 3 | public class RedheadDuck implements Quackable { 4 | public void quack() { 5 | System.out.println("Quack"); 6 | } 7 | 8 | public String toString() { 9 | return "Redhead Duck"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/factory/MallardDuck.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.factory; 2 | 3 | public class MallardDuck implements Quackable { 4 | 5 | public void quack() { 6 | System.out.println("Quack"); 7 | } 8 | 9 | public String toString() { 10 | return "Mallard Duck"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/factory/RubberDuck.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.factory; 2 | 3 | public class RubberDuck implements Quackable { 4 | 5 | public void quack() { 6 | System.out.println("Squeak"); 7 | } 8 | 9 | public String toString() { 10 | return "Rubber Duck"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/decorator/starbuzz/Beverage.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.decorator.starbuzz; 2 | 3 | public abstract class Beverage { 4 | String description = "Unknown Beverage"; 5 | 6 | public String getDescription() { 7 | return description; 8 | } 9 | 10 | public abstract double cost(); 11 | } 12 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/decorator/starbuzzWithSizes/Espresso.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.decorator.starbuzzWithSizes; 2 | 3 | public class Espresso extends Beverage { 4 | 5 | public Espresso() { 6 | description = "Espresso"; 7 | } 8 | 9 | public double cost() { 10 | return 1.99; 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/state/gumballstatewinner/State.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.state.gumballstatewinner; 2 | 3 | public interface State { 4 | 5 | public void insertQuarter(); 6 | public void ejectQuarter(); 7 | public void turnCrank(); 8 | public void dispense(); 9 | 10 | public void refill(); 11 | } 12 | -------------------------------------------------------------------------------- /src/Strategy/Example2/TaxCalculationException.php: -------------------------------------------------------------------------------- 1 | >"); 7 | } 8 | 9 | public String toString() { 10 | return "Decoy Duck"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/decorator/starbuzzWithSizes/DarkRoast.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.decorator.starbuzzWithSizes; 2 | 3 | public class DarkRoast extends Beverage { 4 | public DarkRoast() { 5 | description = "Dark Roast Coffee"; 6 | } 7 | 8 | public double cost() { 9 | return .99; 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/decorator/starbuzzWithSizes/HouseBlend.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.decorator.starbuzzWithSizes; 2 | 3 | public class HouseBlend extends Beverage { 4 | public HouseBlend() { 5 | description = "House Blend Coffee"; 6 | } 7 | 8 | public double cost() { 9 | return .89; 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /src/Command/RemoteControl/NoCommand.php: -------------------------------------------------------------------------------- 1 | >"); 7 | } 8 | 9 | public String toString() { 10 | return "Decoy Duck"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/decorator/DecoyDuck.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.decorator; 2 | 3 | public class DecoyDuck implements Quackable { 4 | 5 | public void quack() { 6 | System.out.println("<< Silence >>"); 7 | } 8 | 9 | public String toString() { 10 | return "Decoy Duck"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/composite/menu/Waitress.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.composite.menu; 2 | 3 | public class Waitress { 4 | MenuComponent allMenus; 5 | 6 | public Waitress(MenuComponent allMenus) { 7 | this.allMenus = allMenus; 8 | } 9 | 10 | public void printMenu() { 11 | allMenus.print(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/proxy/gumballmonitor/State.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.proxy.gumballmonitor; 2 | 3 | import java.io.*; 4 | 5 | public interface State extends Serializable { 6 | 7 | public void insertQuarter(); 8 | public void ejectQuarter(); 9 | public void turnCrank(); 10 | public void dispense(); 11 | } 12 | -------------------------------------------------------------------------------- /weburg/headfirst/singleton/chocolate/ChocolateController.php: -------------------------------------------------------------------------------- 1 | fill(); 6 | $boiler->boil(); 7 | $boiler->drain(); 8 | 9 | // will return the existing instance 10 | $boiler2 = ChocolateBoiler::getInstance(); 11 | } 12 | } 13 | ?> -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combined/djview/DJTestDrive.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combined.djview; 2 | 3 | public class DJTestDrive { 4 | 5 | public static void main (String[] args) { 6 | BeatModelInterface model = new BeatModel(); 7 | ControllerInterface controller = new BeatController(model); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/strategy/DecoyDuck.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.strategy; 2 | 3 | public class DecoyDuck extends Duck { 4 | public DecoyDuck() { 5 | setFlyBehavior(new FlyNoWay()); 6 | setQuackBehavior(new MuteQuack()); 7 | } 8 | public void display() { 9 | System.out.println("I'm a duck Decoy"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/strategy/ModelDuck.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.strategy; 2 | 3 | public class ModelDuck extends Duck { 4 | public ModelDuck() { 5 | flyBehavior = new FlyNoWay(); 6 | quackBehavior = new Quack(); 7 | } 8 | 9 | public void display() { 10 | System.out.println("I'm a model duck"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Factory/PizzaFactoryMethod/CreatePizzaException.php: -------------------------------------------------------------------------------- 1 | createPizza($type); 7 | println("--- Making a " . $pizza->getName() . " ---"); 8 | $pizza->prepare(); 9 | $pizza->bake(); 10 | $pizza->cut(); 11 | $pizza->box(); 12 | return $pizza; 13 | } 14 | } 15 | ?> -------------------------------------------------------------------------------- /weburg/headfirst/proxy/javaproxy/PersonBean.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combined/djview/HeartModelInterface.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combined.djview; 2 | 3 | public interface HeartModelInterface { 4 | int getHeartRate(); 5 | void registerObserver(BeatObserver o); 6 | void removeObserver(BeatObserver o); 7 | void registerObserver(BPMObserver o); 8 | void removeObserver(BPMObserver o); 9 | } 10 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/decorator/starbuzzWithSizes/CondimentDecorator.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.decorator.starbuzzWithSizes; 2 | 3 | public abstract class CondimentDecorator extends Beverage { 4 | public Beverage beverage; 5 | public abstract String getDescription(); 6 | 7 | public Size getSize() { 8 | return beverage.getSize(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/singleton/subclass/CoolerSingleton.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.singleton.subclass; 2 | 3 | public class CoolerSingleton extends Singleton { 4 | // useful instance variables here 5 | protected static Singleton uniqueInstance; 6 | 7 | private CoolerSingleton() { 8 | super(); 9 | } 10 | 11 | // useful methods here 12 | } 13 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/strategy/RedHeadDuck.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.strategy; 2 | 3 | public class RedHeadDuck extends Duck { 4 | 5 | public RedHeadDuck() { 6 | flyBehavior = new FlyWithWings(); 7 | quackBehavior = new Quack(); 8 | } 9 | 10 | public void display() { 11 | System.out.println("I'm a real Red Headed duck"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/TemplateMethod/SimpleBarista/Java/Barista.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.templatemethod.simplebarista; 2 | 3 | public class Barista { 4 | 5 | public static void main(String[] args) { 6 | Tea tea = new Tea(); 7 | Coffee coffee = new Coffee(); 8 | System.out.println("Making tea..."); 9 | tea.prepareRecipe(); 10 | System.out.println("Making coffee..."); 11 | coffee.prepareRecipe(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzas/CheesePizza.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzas; 2 | 3 | public class CheesePizza extends Pizza { 4 | public CheesePizza() { 5 | name = "Cheese Pizza"; 6 | dough = "Regular Crust"; 7 | sauce = "Marinara Pizza Sauce"; 8 | toppings.add("Fresh Mozzarella"); 9 | toppings.add("Parmesan"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/proxy/gumball/GumballMachineRemote.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.proxy.gumball; 2 | 3 | import java.rmi.*; 4 | 5 | public interface GumballMachineRemote extends Remote { 6 | public int getCount() throws RemoteException; 7 | public String getLocation() throws RemoteException; 8 | public State getState() throws RemoteException; 9 | } 10 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/strategy/MallardDuck.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.strategy; 2 | 3 | public class MallardDuck extends Duck { 4 | 5 | public MallardDuck() { 6 | 7 | quackBehavior = new Quack(); 8 | flyBehavior = new FlyWithWings(); 9 | 10 | } 11 | 12 | public void display() { 13 | System.out.println("I'm a real Mallard duck"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Strategy/Example1/FlyBehavior/FlyBehavior.php: -------------------------------------------------------------------------------- 1 | goose = $goose; 10 | } 11 | 12 | public function quack() { 13 | $this->goose->honk(); 14 | } 15 | 16 | public function __toString() { 17 | return "Goose pretending to be a Duck"; 18 | } 19 | } 20 | ?> -------------------------------------------------------------------------------- /weburg/headfirst/combining/composite/GooseAdapter.php: -------------------------------------------------------------------------------- 1 | goose = $goose; 10 | } 11 | 12 | public function quack() { 13 | $this->goose->honk(); 14 | } 15 | 16 | public function __toString() { 17 | return "Goose pretending to be a Duck"; 18 | } 19 | } 20 | ?> -------------------------------------------------------------------------------- /weburg/headfirst/combining/decorator/GooseAdapter.php: -------------------------------------------------------------------------------- 1 | goose = $goose; 10 | } 11 | 12 | public function quack() { 13 | $this->goose->honk(); 14 | } 15 | 16 | public function __toString() { 17 | return "Goose pretending to be a Duck"; 18 | } 19 | } 20 | ?> -------------------------------------------------------------------------------- /weburg/headfirst/combining/factory/GooseAdapter.php: -------------------------------------------------------------------------------- 1 | goose = $goose; 10 | } 11 | 12 | public function quack() { 13 | $this->goose->honk(); 14 | } 15 | 16 | public function __toString() { 17 | return "Goose pretending to be a Duck"; 18 | } 19 | } 20 | ?> -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/observer/Quackologist.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.observer; 2 | 3 | public class Quackologist implements Observer { 4 | 5 | public void update(QuackObservable duck) { 6 | System.out.println("Quackologist: " + duck + " just quacked."); 7 | } 8 | 9 | public String toString() { 10 | return "Quackologist"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/factory/AbstractDuckFactory.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.factory; 2 | 3 | public abstract class AbstractDuckFactory { 4 | 5 | public abstract Quackable createMallardDuck(); 6 | public abstract Quackable createRedheadDuck(); 7 | public abstract Quackable createDuckCall(); 8 | public abstract Quackable createRubberDuck(); 9 | } 10 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/observer/AbstractDuckFactory.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.observer; 2 | 3 | public abstract class AbstractDuckFactory { 4 | 5 | public abstract Quackable createMallardDuck(); 6 | public abstract Quackable createRedheadDuck(); 7 | public abstract Quackable createDuckCall(); 8 | public abstract Quackable createRubberDuck(); 9 | } 10 | -------------------------------------------------------------------------------- /src/Strategy/Example1/QuackBehavior/QuackBehavior.php: -------------------------------------------------------------------------------- 1 | gobble(); 13 | $duckAdapter->fly(); 14 | } 15 | -------------------------------------------------------------------------------- /weburg/headfirst/singleton/classic/runSingleton.php: -------------------------------------------------------------------------------- 1 | value = 4; 8 | println("Object now has instance value of " . $myInstance->value); 9 | 10 | $myInstance2 = Singleton::getInstance(); 11 | println("After getting another instance, value should be the same: " . $myInstance2->value); 12 | ?> -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/PizzaIngredientFactory.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public interface PizzaIngredientFactory { 4 | 5 | public Dough createDough(); 6 | public Sauce createSauce(); 7 | public Cheese createCheese(); 8 | public Veggies[] createVeggies(); 9 | public Pepperoni createPepperoni(); 10 | public Clams createClam(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/Command/UndoRemoteControl/NoCommand.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/factory/DuckFactory.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/observer/DuckFactory.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzas/PepperoniPizza.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzas; 2 | 3 | public class PepperoniPizza extends Pizza { 4 | public PepperoniPizza() { 5 | name = "Pepperoni Pizza"; 6 | dough = "Crust"; 7 | sauce = "Marinara sauce"; 8 | toppings.add("Sliced Pepperoni"); 9 | toppings.add("Sliced Onion"); 10 | toppings.add("Grated parmesan cheese"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "maksi/head-first-design-pattern", 3 | "authors": [ 4 | { 5 | "name": "Tetiana Blindaruk", 6 | "email": "t.blindaruk@gmail.com" 7 | } 8 | ], 9 | "autoload":{ 10 | "psr-4":{ 11 | "Maksi\\HeadFirstDesignPattern\\":"src" 12 | } 13 | }, 14 | "config": { 15 | "sort-packages": true, 16 | "optimize-autoloader": true 17 | }, 18 | "require": {} 19 | } 20 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/adapter/GooseAdapter.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.adapter; 2 | 3 | public class GooseAdapter implements Quackable { 4 | Goose goose; 5 | 6 | public GooseAdapter(Goose goose) { 7 | this.goose = goose; 8 | } 9 | 10 | public void quack() { 11 | goose.honk(); 12 | } 13 | 14 | public String toString() { 15 | return "Goose pretending to be a Duck"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/ducks/TurkeyAdapter.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.ducks; 2 | 3 | public class TurkeyAdapter implements Duck { 4 | Turkey turkey; 5 | 6 | public TurkeyAdapter(Turkey turkey) { 7 | this.turkey = turkey; 8 | } 9 | 10 | public void quack() { 11 | turkey.gobble(); 12 | } 13 | 14 | public void fly() { 15 | for(int i=0; i < 5; i++) { 16 | turkey.fly(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Command/Party/NoCommand.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/singleton/chocolate/ChocolateController.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.singleton.chocolate; 2 | 3 | public class ChocolateController { 4 | public static void main(String args[]) { 5 | ChocolateBoiler boiler = ChocolateBoiler.getInstance(); 6 | boiler.fill(); 7 | boiler.boil(); 8 | boiler.drain(); 9 | 10 | // will return the existing instance 11 | ChocolateBoiler boiler2 = ChocolateBoiler.getInstance(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Adapter/Ducks/WildTurkey.php: -------------------------------------------------------------------------------- 1 | boilWater(); 5 | $this->brew(); 6 | $this->pourInCup(); 7 | $this->addCondiments(); 8 | } 9 | 10 | abstract protected function brew(); 11 | 12 | abstract protected function addCondiments(); 13 | 14 | protected function boilWater() { 15 | println("Boiling water"); 16 | } 17 | 18 | protected function pourInCup() { 19 | println("Pouring into cup"); 20 | } 21 | } 22 | ?> -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/iterenum/EnumerationIteratorTestDrive.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.iterenum; 2 | 3 | import java.util.*; 4 | 5 | public class EnumerationIteratorTestDrive { 6 | public static void main (String args[]) { 7 | Vector v = new Vector(Arrays.asList(args)); 8 | Iterator iterator = new EnumerationIterator(v.elements()); 9 | while (iterator.hasNext()) { 10 | System.out.println(iterator.next()); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /weburg/headfirst/proxy/gumballmonitor/GumballMonitor.php: -------------------------------------------------------------------------------- 1 | machine = $machine; 10 | } 11 | 12 | public function report() { 13 | println("Gumball Machine: " . $this->machine->getLocation()); 14 | println("Current inventory: " . $this->machine->getCount() . " gumballs"); 15 | println("Current state: " . $this->machine->getState()); 16 | } 17 | } 18 | ?> -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzafm/PizzaStore.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzafm; 2 | 3 | public abstract class PizzaStore { 4 | 5 | abstract Pizza createPizza(String item); 6 | 7 | public Pizza orderPizza(String type) { 8 | Pizza pizza = createPizza(type); 9 | System.out.println("--- Making a " + pizza.getName() + " ---"); 10 | pizza.prepare(); 11 | pizza.bake(); 12 | pizza.cut(); 13 | pizza.box(); 14 | return pizza; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/TemplateMethod/Barista/Java/CaffeineBeverage.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.templatemethod.barista; 2 | 3 | public abstract class CaffeineBeverage { 4 | 5 | final void prepareRecipe() { 6 | boilWater(); 7 | brew(); 8 | pourInCup(); 9 | addCondiments(); 10 | } 11 | 12 | abstract void brew(); 13 | 14 | abstract void addCondiments(); 15 | 16 | void boilWater() { 17 | System.out.println("Boiling water"); 18 | } 19 | 20 | void pourInCup() { 21 | System.out.println("Pouring into cup"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/factory/CountingDuckFactory.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/observer/CountingDuckFactory.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/ducks/DuckAdapter.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.ducks; 2 | import java.util.Random; 3 | 4 | public class DuckAdapter implements Turkey { 5 | Duck duck; 6 | Random rand; 7 | 8 | public DuckAdapter(Duck duck) { 9 | this.duck = duck; 10 | rand = new Random(); 11 | } 12 | 13 | public void gobble() { 14 | duck.quack(); 15 | } 16 | 17 | public void fly() { 18 | if (rand.nextInt(5) == 0) { 19 | duck.fly(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/PizzaStore.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public abstract class PizzaStore { 4 | 5 | protected abstract Pizza createPizza(String item); 6 | 7 | public Pizza orderPizza(String type) { 8 | Pizza pizza = createPizza(type); 9 | System.out.println("--- Making a " + pizza.getName() + " ---"); 10 | pizza.prepare(); 11 | pizza.bake(); 12 | pizza.cut(); 13 | pizza.box(); 14 | return pizza; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/composite/CountingDuckFactory.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/TemplateMethod/SimpleBarista/Tea.php: -------------------------------------------------------------------------------- 1 | boilWater(); 5 | $this->steepTeaBag(); 6 | $this->pourInCup(); 7 | $this->addLemon(); 8 | } 9 | 10 | public function boilWater() { 11 | println("Boiling water"); 12 | } 13 | 14 | public function steepTeaBag() { 15 | println("Steeping the tea"); 16 | } 17 | 18 | public function addLemon() { 19 | println("Adding Lemon"); 20 | } 21 | 22 | public function pourInCup() { 23 | println("Pouring into cup"); 24 | } 25 | } 26 | ?> -------------------------------------------------------------------------------- /weburg/headfirst/combined/djviewweb/application/models/BeatModel.php: -------------------------------------------------------------------------------- 1 | setBPM(90); 10 | } 11 | 12 | public function off() { 13 | $this->setBPM(0); 14 | } 15 | 16 | public function setBPM($bpm) { 17 | $this->bpm = $bpm; 18 | } 19 | 20 | public function getBPM() { 21 | return $this->bpm; 22 | } 23 | } 24 | ?> -------------------------------------------------------------------------------- /weburg/headfirst/proxy/gumball/GumballMachineTestDrive.php: -------------------------------------------------------------------------------- 1 | "); 11 | exit(); 12 | } 13 | 14 | $count = $args[1]; 15 | 16 | $gumballMachine = new GumballMachine($args[0], $count); 17 | 18 | Proxy::runServer($args[0], $gumballMachine, "GumballMachineRemote"); 19 | } 20 | } 21 | ?> -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/iterenum/IteratorEnumerationTestDrive.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.iterenum; 2 | 3 | import java.util.*; 4 | 5 | public class IteratorEnumerationTestDrive { 6 | public static void main (String args[]) { 7 | ArrayList l = new ArrayList(Arrays.asList(args)); 8 | Enumeration enumeration = new IteratorEnumeration(l.iterator()); 9 | while (enumeration.hasMoreElements()) { 10 | System.out.println(enumeration.nextElement()); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /documentation/10-template-method.md: -------------------------------------------------------------------------------- 1 | ## Template method 2 | 3 | Патерн Шаблонный метод задает "скелет" алгоритма в методе, оставляе определение реализации некоторых шагов субкассам. Субклассы могут переопределять некоторые части алгоритма без изменения его структуры. 4 | 5 | ![TemplateMethod](./../src/TemplateMethod/UML.png) 6 | 7 | 8 | ### Example 9 | - [SimpleBarista](./../src/TemplateMethod/SimpleBarista) 10 | - [Barista](./../src/TemplateMethod/Barista) 11 | 12 | ### TODO: 13 | - [ ] refactoring of `SimpleBarista` 14 | - [ ] refactoring of `Barista` -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combined/djview/BeatModelInterface.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combined.djview; 2 | 3 | public interface BeatModelInterface { 4 | void initialize(); 5 | 6 | void on(); 7 | 8 | void off(); 9 | 10 | void setBPM(int bpm); 11 | 12 | int getBPM(); 13 | 14 | void registerObserver(BeatObserver o); 15 | 16 | void removeObserver(BeatObserver o); 17 | 18 | void registerObserver(BPMObserver o); 19 | 20 | void removeObserver(BPMObserver o); 21 | } 22 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzafm/NYStyleVeggiePizza.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzafm; 2 | 3 | public class NYStyleVeggiePizza extends Pizza { 4 | 5 | public NYStyleVeggiePizza() { 6 | name = "NY Style Veggie Pizza"; 7 | dough = "Thin Crust Dough"; 8 | sauce = "Marinara Sauce"; 9 | 10 | toppings.add("Grated Reggiano Cheese"); 11 | toppings.add("Garlic"); 12 | toppings.add("Onion"); 13 | toppings.add("Mushrooms"); 14 | toppings.add("Red Pepper"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/iterenum/IteratorEnumeration.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.iterenum; 2 | 3 | import java.util.*; 4 | 5 | public class IteratorEnumeration implements Enumeration { 6 | Iterator iterator; 7 | 8 | public IteratorEnumeration(Iterator iterator) { 9 | this.iterator = iterator; 10 | } 11 | 12 | public boolean hasMoreElements() { 13 | return iterator.hasNext(); 14 | } 15 | 16 | public Object nextElement() { 17 | return iterator.next(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/proxy/gumball/README.md: -------------------------------------------------------------------------------- 1 | # Gumball Machine with Proxy Pattern 2 | 3 | To get code running on localhost: 4 | 5 | 1. Change directories to the same level with headfirst/ folder in bin/ 6 | 7 | 2. Run rmiregistry in background: 8 | rmiregistry & 9 | 10 | 3. Run: 11 | java headfirst/designpatterns/proxy/gumball/GumballMachineTestDrive localhost 300 12 | 13 | 4. In a different window, run: 14 | java headfirst/designpatterns/proxy/gumball/GumballMonitorTestDrive localhost 15 | 16 | 17 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/singleton/subclass/Singleton.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.singleton.subclass; 2 | 3 | public class Singleton { 4 | protected static Singleton uniqueInstance; 5 | 6 | // other useful instance variables here 7 | 8 | protected Singleton() {} 9 | 10 | public static synchronized Singleton getInstance() { 11 | if (uniqueInstance == null) { 12 | uniqueInstance = new Singleton(); 13 | } 14 | return uniqueInstance; 15 | } 16 | 17 | // other useful methods here 18 | } 19 | -------------------------------------------------------------------------------- /src/Facade/HomeTheater/Screen.php: -------------------------------------------------------------------------------- 1 | description = $description; 11 | } 12 | 13 | public function up() { 14 | println($this->description . " going up"); 15 | } 16 | 17 | public function down() { 18 | println($this->description . " going down"); 19 | } 20 | 21 | public function __toString() { 22 | return $this->description; 23 | } 24 | } 25 | ?> -------------------------------------------------------------------------------- /weburg/headfirst/state/gumballstate/GumballMachineTestDrive.php: -------------------------------------------------------------------------------- 1 | insertQuarter(); 9 | $gumballMachine->turnCrank(); 10 | 11 | println($gumballMachine); 12 | 13 | $gumballMachine->insertQuarter(); 14 | $gumballMachine->turnCrank(); 15 | $gumballMachine->insertQuarter(); 16 | $gumballMachine->turnCrank(); 17 | 18 | println($gumballMachine); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzafm/ChicagoStyleCheesePizza.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzafm; 2 | 3 | public class ChicagoStyleCheesePizza extends Pizza { 4 | 5 | public ChicagoStyleCheesePizza() { 6 | name = "Chicago Style Deep Dish Cheese Pizza"; 7 | dough = "Extra Thick Crust Dough"; 8 | sauce = "Plum Tomato Sauce"; 9 | 10 | toppings.add("Shredded Mozzarella Cheese"); 11 | } 12 | 13 | void cut() { 14 | System.out.println("Cutting the pizza into square slices"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzas/PizzaStore.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzas; 2 | 3 | public class PizzaStore { 4 | SimplePizzaFactory factory; 5 | 6 | public PizzaStore(SimplePizzaFactory factory) { 7 | this.factory = factory; 8 | } 9 | 10 | public Pizza orderPizza(String type) { 11 | Pizza pizza; 12 | 13 | pizza = factory.createPizza(type); 14 | 15 | pizza.prepare(); 16 | pizza.bake(); 17 | pizza.cut(); 18 | pizza.box(); 19 | 20 | return pizza; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzas/VeggiePizza.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzas; 2 | 3 | public class VeggiePizza extends Pizza { 4 | public VeggiePizza() { 5 | name = "Veggie Pizza"; 6 | dough = "Crust"; 7 | sauce = "Marinara sauce"; 8 | toppings.add("Shredded mozzarella"); 9 | toppings.add("Grated parmesan"); 10 | toppings.add("Diced onion"); 11 | toppings.add("Sliced mushrooms"); 12 | toppings.add("Sliced red pepper"); 13 | toppings.add("Sliced black olives"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Observer/Example1/Observer.php: -------------------------------------------------------------------------------- 1 | prepareRecipe(); 9 | 10 | println("\nMaking coffee..."); 11 | $coffee->prepareRecipe(); 12 | 13 | 14 | $teaHook = new TeaWithHook(); 15 | $coffeeHook = new CoffeeWithHook(); 16 | 17 | println("\nMaking tea..."); 18 | $teaHook->prepareRecipe(); 19 | 20 | println("\nMaking coffee..."); 21 | $coffeeHook->prepareRecipe(); 22 | } 23 | } 24 | ?> -------------------------------------------------------------------------------- /src/TemplateMethod/SimpleBarista/Coffee.php: -------------------------------------------------------------------------------- 1 | boilWater(); 5 | $this->brewCoffeeGrinds(); 6 | $this->pourInCup(); 7 | $this->addSugarAndMilk(); 8 | } 9 | 10 | public function boilWater() { 11 | println("Boiling water"); 12 | } 13 | 14 | public function brewCoffeeGrinds() { 15 | println("Dripping Coffee through filter"); 16 | } 17 | 18 | public function pourInCup() { 19 | println("Pouring into cup"); 20 | } 21 | 22 | public function addSugarAndMilk() { 23 | println("Adding Sugar and Milk"); 24 | } 25 | } 26 | ?> -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/decorator/QuackCounter.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.decorator; 2 | 3 | public class QuackCounter implements Quackable { 4 | Quackable duck; 5 | static int numberOfQuacks; 6 | 7 | public QuackCounter (Quackable duck) { 8 | this.duck = duck; 9 | } 10 | 11 | public void quack() { 12 | duck.quack(); 13 | numberOfQuacks++; 14 | } 15 | 16 | public static int getQuacks() { 17 | return numberOfQuacks; 18 | } 19 | public String toString() { 20 | return duck.toString(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzafm/ChicagoStyleClamPizza.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzafm; 2 | 3 | public class ChicagoStyleClamPizza extends Pizza { 4 | public ChicagoStyleClamPizza() { 5 | name = "Chicago Style Clam Pizza"; 6 | dough = "Extra Thick Crust Dough"; 7 | sauce = "Plum Tomato Sauce"; 8 | 9 | toppings.add("Shredded Mozzarella Cheese"); 10 | toppings.add("Frozen Clams from Chesapeake Bay"); 11 | } 12 | 13 | void cut() { 14 | System.out.println("Cutting the pizza into square slices"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/iterator/transition/MenuTestDrive.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.iterator.transition; 2 | import java.util.ArrayList; 3 | 4 | public class MenuTestDrive { 5 | public static void main(String args[]) { 6 | PancakeHouseMenu pancakeHouseMenu = new PancakeHouseMenu(); 7 | DinerMenu dinerMenu = new DinerMenu(); 8 | ArrayList menus = new ArrayList(); 9 | menus.add(pancakeHouseMenu); 10 | menus.add(dinerMenu); 11 | Waitress waitress = new Waitress(menus); 12 | waitress.printMenu(); 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/proxy/gumballmonitor/GumballMonitor.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.proxy.gumballmonitor; 2 | 3 | public class GumballMonitor { 4 | GumballMachine machine; 5 | 6 | public GumballMonitor(GumballMachine machine) { 7 | this.machine = machine; 8 | } 9 | 10 | public void report() { 11 | System.out.println("Gumball Machine: " + machine.getLocation()); 12 | System.out.println("Current inventory: " + machine.getCount() + " gumballs"); 13 | System.out.println("Current state: " + machine.getState()); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/CheesePizza.php: -------------------------------------------------------------------------------- 1 | ingredientFactory = $ingredientFactory; 10 | } 11 | 12 | public function prepare() { 13 | println("Preparing " . $this->name); 14 | $this->dough = $this->ingredientFactory->createDough(); 15 | $this->sauce = $this->ingredientFactory->createSauce(); 16 | $this->cheese = $this->ingredientFactory->createCheese(); 17 | } 18 | } 19 | ?> -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/factory/QuackCounter.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.factory; 2 | 3 | public class QuackCounter implements Quackable { 4 | Quackable duck; 5 | static int numberOfQuacks; 6 | 7 | public QuackCounter(Quackable duck) { 8 | this.duck = duck; 9 | } 10 | 11 | public void quack() { 12 | duck.quack(); 13 | numberOfQuacks++; 14 | } 15 | 16 | public static int getQuacks() { 17 | return numberOfQuacks; 18 | } 19 | 20 | public String toString() { 21 | return duck.toString(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzafm/NYStylePepperoniPizza.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzafm; 2 | 3 | public class NYStylePepperoniPizza extends Pizza { 4 | 5 | public NYStylePepperoniPizza() { 6 | name = "NY Style Pepperoni Pizza"; 7 | dough = "Thin Crust Dough"; 8 | sauce = "Marinara Sauce"; 9 | 10 | toppings.add("Grated Reggiano Cheese"); 11 | toppings.add("Sliced Pepperoni"); 12 | toppings.add("Garlic"); 13 | toppings.add("Onion"); 14 | toppings.add("Mushrooms"); 15 | toppings.add("Red Pepper"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/composite/QuackCounter.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.composite; 2 | 3 | public class QuackCounter implements Quackable { 4 | Quackable duck; 5 | static int numberOfQuacks; 6 | 7 | public QuackCounter(Quackable duck) { 8 | this.duck = duck; 9 | } 10 | 11 | public void quack() { 12 | duck.quack(); 13 | numberOfQuacks++; 14 | } 15 | 16 | public static int getQuacks() { 17 | return numberOfQuacks; 18 | } 19 | 20 | public String toString() { 21 | return duck.toString(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/decorator/starbuzzWithSizes/Beverage.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.decorator.starbuzzWithSizes; 2 | 3 | public abstract class Beverage { 4 | public enum Size { TALL, GRANDE, VENTI }; 5 | Size size = Size.TALL; 6 | String description = "Unknown Beverage"; 7 | 8 | public String getDescription() { 9 | return description; 10 | } 11 | 12 | public void setSize(Size size) { 13 | this.size = size; 14 | } 15 | 16 | public Size getSize() { 17 | return this.size; 18 | } 19 | 20 | public abstract double cost(); 21 | } 22 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/CheesePizza.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public class CheesePizza extends Pizza { 4 | PizzaIngredientFactory ingredientFactory; 5 | 6 | public CheesePizza(PizzaIngredientFactory ingredientFactory) { 7 | this.ingredientFactory = ingredientFactory; 8 | } 9 | 10 | void prepare() { 11 | System.out.println("Preparing " + name); 12 | dough = ingredientFactory.createDough(); 13 | sauce = ingredientFactory.createSauce(); 14 | cheese = ingredientFactory.createCheese(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzafm/NYPizzaStore.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzafm; 2 | 3 | public class NYPizzaStore extends PizzaStore { 4 | 5 | Pizza createPizza(String item) { 6 | if (item.equals("cheese")) { 7 | return new NYStyleCheesePizza(); 8 | } else if (item.equals("veggie")) { 9 | return new NYStyleVeggiePizza(); 10 | } else if (item.equals("clam")) { 11 | return new NYStyleClamPizza(); 12 | } else if (item.equals("pepperoni")) { 13 | return new NYStylePepperoniPizza(); 14 | } else return null; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/TemplateMethod/SimpleBarista/Java/Tea.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.templatemethod.simplebarista; 2 | 3 | public class Tea { 4 | 5 | void prepareRecipe() { 6 | boilWater(); 7 | steepTeaBag(); 8 | pourInCup(); 9 | addLemon(); 10 | } 11 | 12 | public void boilWater() { 13 | System.out.println("Boiling water"); 14 | } 15 | 16 | public void steepTeaBag() { 17 | System.out.println("Steeping the tea"); 18 | } 19 | 20 | public void addLemon() { 21 | System.out.println("Adding Lemon"); 22 | } 23 | 24 | public void pourInCup() { 25 | System.out.println("Pouring into cup"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /documentation/7-command.md: -------------------------------------------------------------------------------- 1 | ## Command 2 | 3 | Патерн Команда инкапсулирует запрос в виде обьекта, делая возможной параметризацию клиентских обьектов с другими запросами, организацию очереди или регистрацию запросов, а также подержку отмену операций. 4 | 5 | ![Command](./../src/Command/UML.png) 6 | 7 | 8 | ### Example 9 | 10 | - [SimpleControl](./../src/Command/SimpleControl) 11 | - [RemoteControl](./../src/Command/RemoteControl) 12 | 13 | ![Command](./../src/Command/RemoteControl/UML.png) 14 | 15 | - [RemoteControlWithUndo](./../src/Command/UndoRemoteControl) 16 | - [MultiControl](./../src/Command/Party) 17 | -------------------------------------------------------------------------------- /src/Factory/PizzaSimpleFactory/index.php: -------------------------------------------------------------------------------- 1 | orderPizza('cheese'); 13 | echo 'We ordered a ' . (string) $pizza . PHP_EOL; 14 | echo '---------------------' . PHP_EOL; 15 | 16 | $pizza = $store->orderPizza('veggie'); 17 | echo 'We ordered a ' . (string) $pizza . PHP_EOL; 18 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzas/SimplePizzaFactory.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzas; 2 | 3 | public class SimplePizzaFactory { 4 | 5 | public Pizza createPizza(String type) { 6 | Pizza pizza = null; 7 | 8 | if (type.equals("cheese")) { 9 | pizza = new CheesePizza(); 10 | } else if (type.equals("pepperoni")) { 11 | pizza = new PepperoniPizza(); 12 | } else if (type.equals("clam")) { 13 | pizza = new ClamPizza(); 14 | } else if (type.equals("veggie")) { 15 | pizza = new VeggiePizza(); 16 | } 17 | return pizza; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/singleton/classic/Singleton.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.singleton.classic; 2 | 3 | // NOTE: This is not thread safe! 4 | 5 | public class Singleton { 6 | private static Singleton uniqueInstance; 7 | 8 | private Singleton() {} 9 | 10 | public static Singleton getInstance() { 11 | if (uniqueInstance == null) { 12 | uniqueInstance = new Singleton(); 13 | } 14 | return uniqueInstance; 15 | } 16 | 17 | // other useful methods here 18 | public String getDescription() { 19 | return "I'm a classic Singleton!"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Command/SimpleControl/SimpleRemoteControl.php: -------------------------------------------------------------------------------- 1 | command = $command; 21 | } 22 | 23 | public function buttonWasPressed():void 24 | { 25 | $this->command->execute(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/factory/QuackCounter.php: -------------------------------------------------------------------------------- 1 | duck = $duck; 14 | } 15 | 16 | public function quack() { 17 | $this->duck->quack(); 18 | self::$numberOfQuacks++; 19 | } 20 | 21 | public static function getQuacks() { 22 | return self::$numberOfQuacks; 23 | } 24 | 25 | public function __toString() { 26 | return $this->duck->__toString(); 27 | } 28 | } 29 | ?> 30 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/composite/QuackCounter.php: -------------------------------------------------------------------------------- 1 | duck = $duck; 14 | } 15 | 16 | public function quack() { 17 | $this->duck->quack(); 18 | self::$numberOfQuacks++; 19 | } 20 | 21 | public static function getQuacks() { 22 | return self::$numberOfQuacks; 23 | } 24 | 25 | public function __toString() { 26 | return $this->duck->__toString(); 27 | } 28 | } 29 | ?> 30 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/decorator/QuackCounter.php: -------------------------------------------------------------------------------- 1 | duck = $duck; 14 | } 15 | 16 | public function quack() { 17 | $this->duck->quack(); 18 | self::$numberOfQuacks++; 19 | } 20 | 21 | public static function getQuacks() { 22 | return self::$numberOfQuacks; 23 | } 24 | 25 | public function __toString() { 26 | return $this->duck->__toString(); 27 | } 28 | } 29 | ?> 30 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/decorator/io/InputTest.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.decorator.io; 2 | 3 | import java.io.*; 4 | 5 | public class InputTest { 6 | public static void main(String[] args) throws IOException { 7 | int c; 8 | 9 | try { 10 | InputStream in = 11 | new LowerCaseInputStream( 12 | new BufferedInputStream( 13 | new FileInputStream("test.txt"))); 14 | 15 | while((c = in.read()) >= 0) { 16 | System.out.print((char)c); 17 | } 18 | 19 | in.close(); 20 | } catch (IOException e) { 21 | e.printStackTrace(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /weburg/headfirst/combined/djviewweb/application/bootstrap.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /weburg/headfirst/proxy/gumball/GumballMonitorTestDrive.php: -------------------------------------------------------------------------------- 1 | report(); 22 | } 23 | } 24 | } 25 | ?> -------------------------------------------------------------------------------- /src/Observer/Example1/Subject.php: -------------------------------------------------------------------------------- 1 | { 6 | 7 | public MenuComponent next() { 8 | return null; 9 | } 10 | 11 | public boolean hasNext() { 12 | return false; 13 | } 14 | 15 | /* 16 | * No longer needed as of Java 8 17 | * 18 | * (non-Javadoc) 19 | * @see java.util.Iterator#remove() 20 | * 21 | public void remove() { 22 | throw new UnsupportedOperationException(); 23 | } 24 | */ 25 | } 26 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzafm/ChicagoStyleVeggiePizza.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzafm; 2 | 3 | public class ChicagoStyleVeggiePizza extends Pizza { 4 | public ChicagoStyleVeggiePizza() { 5 | name = "Chicago Deep Dish Veggie Pizza"; 6 | dough = "Extra Thick Crust Dough"; 7 | sauce = "Plum Tomato Sauce"; 8 | 9 | toppings.add("Shredded Mozzarella Cheese"); 10 | toppings.add("Black Olives"); 11 | toppings.add("Spinach"); 12 | toppings.add("Eggplant"); 13 | } 14 | 15 | void cut() { 16 | System.out.println("Cutting the pizza into square slices"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /weburg/headfirst/factory/pizzaaf/ClamPizza.php: -------------------------------------------------------------------------------- 1 | ingredientFactory = $ingredientFactory; 10 | } 11 | 12 | public function prepare() { 13 | println("Preparing " . $this->name); 14 | $this->dough = $this->ingredientFactory->createDough(); 15 | $this->sauce = $this->ingredientFactory->createSauce(); 16 | $this->cheese = $this->ingredientFactory->createCheese(); 17 | $this->clam = $this->ingredientFactory->createClam(); 18 | } 19 | } 20 | ?> -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzaaf/VeggiePizza.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzaaf; 2 | 3 | public class VeggiePizza extends Pizza { 4 | PizzaIngredientFactory ingredientFactory; 5 | 6 | public VeggiePizza(PizzaIngredientFactory ingredientFactory) { 7 | this.ingredientFactory = ingredientFactory; 8 | } 9 | 10 | void prepare() { 11 | System.out.println("Preparing " + name); 12 | dough = ingredientFactory.createDough(); 13 | sauce = ingredientFactory.createSauce(); 14 | cheese = ingredientFactory.createCheese(); 15 | veggies = ingredientFactory.createVeggies(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Facade/HomeTheater/PopcornPopper.php: -------------------------------------------------------------------------------- 1 | description = $description; 11 | } 12 | 13 | public function on() { 14 | println($this->description . " on"); 15 | } 16 | 17 | public function off() { 18 | println($this->description . " off"); 19 | } 20 | 21 | public function pop() { 22 | println($this->description . " popping popcorn!"); 23 | } 24 | 25 | public function __toString() { 26 | return $this->description; 27 | } 28 | } 29 | ?> -------------------------------------------------------------------------------- /src/TemplateMethod/Barista/Java/CaffeineBeverageWithHook.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.templatemethod.barista; 2 | 3 | public abstract class CaffeineBeverageWithHook { 4 | 5 | final void prepareRecipe() { 6 | boilWater(); 7 | brew(); 8 | pourInCup(); 9 | if (customerWantsCondiments()) { 10 | addCondiments(); 11 | } 12 | } 13 | 14 | abstract void brew(); 15 | 16 | abstract void addCondiments(); 17 | 18 | void boilWater() { 19 | System.out.println("Boiling water"); 20 | } 21 | 22 | void pourInCup() { 23 | System.out.println("Pouring into cup"); 24 | } 25 | 26 | boolean customerWantsCondiments() { 27 | return true; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/README.md: -------------------------------------------------------------------------------- 1 | # Head First Design Patterns (2014 update) 2 | 3 | I have recently updated all the code for Head First Design Patterns to be compatible 4 | with Java 8. This new code accompanies an update for the book, released in July, 2014. 5 | 6 | Download the code and compile and run from the command line, or load the code into 7 | project in Eclipse (Kepler, with the Java 8 beta patch). 8 | 9 | https://wiki.eclipse.org/JDT/Eclipse_Java_8_Support_For_Kepler 10 | 11 | 12 | Other links for the book are available on the book page at wickedlysmart.com. 13 | 14 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/iterenum/EnumerationIterator.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.iterenum; 2 | 3 | import java.util.*; 4 | 5 | public class EnumerationIterator implements Iterator { 6 | Enumeration enumeration; 7 | 8 | public EnumerationIterator(Enumeration enumeration) { 9 | this.enumeration = enumeration; 10 | } 11 | 12 | public boolean hasNext() { 13 | return enumeration.hasMoreElements(); 14 | } 15 | 16 | public Object next() { 17 | return enumeration.nextElement(); 18 | } 19 | 20 | public void remove() { 21 | throw new UnsupportedOperationException(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/singleton/dcl/Singleton.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.singleton.dcl; 2 | 3 | // 4 | // Danger! This implementation of Singleton not 5 | // guaranteed to work prior to Java 5 6 | // 7 | 8 | public class Singleton { 9 | private volatile static Singleton uniqueInstance; 10 | 11 | private Singleton() {} 12 | 13 | public static Singleton getInstance() { 14 | if (uniqueInstance == null) { 15 | synchronized (Singleton.class) { 16 | if (uniqueInstance == null) { 17 | uniqueInstance = new Singleton(); 18 | } 19 | } 20 | } 21 | return uniqueInstance; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/TemplateMethod/SimpleBarista/Java/Coffee.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.templatemethod.simplebarista; 2 | 3 | public class Coffee { 4 | 5 | void prepareRecipe() { 6 | boilWater(); 7 | brewCoffeeGrinds(); 8 | pourInCup(); 9 | addSugarAndMilk(); 10 | } 11 | 12 | public void boilWater() { 13 | System.out.println("Boiling water"); 14 | } 15 | 16 | public void brewCoffeeGrinds() { 17 | System.out.println("Dripping Coffee through filter"); 18 | } 19 | 20 | public void pourInCup() { 21 | System.out.println("Pouring into cup"); 22 | } 23 | 24 | public void addSugarAndMilk() { 25 | System.out.println("Adding Sugar and Milk"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/observer/DuckCall.php: -------------------------------------------------------------------------------- 1 | observable = new Observable($this); 10 | } 11 | 12 | public function quack() { 13 | println("Kwak"); 14 | $this->notifyObservers(); 15 | } 16 | 17 | public function registerObserver(Observer $observer) { 18 | $this->observable->registerObserver($observer); 19 | } 20 | 21 | public function notifyObservers() { 22 | $this->observable->notifyObservers(); 23 | } 24 | 25 | public function __toString() { 26 | return "Duck Call"; 27 | } 28 | } 29 | ?> -------------------------------------------------------------------------------- /weburg/headfirst/iterator/dinermerger/ArrayIterator.php: -------------------------------------------------------------------------------- 1 | items = $items; 11 | } 12 | 13 | public function next() { 14 | $menuItem = $this->items[$this->position]; 15 | $this->position = $this->position + 1; 16 | return $menuItem; 17 | } 18 | 19 | public function hasNext() { 20 | if ($this->position >= count($this->items) || $this->items[$this->position] == NULL) { 21 | return FALSE; 22 | } else { 23 | return TRUE; 24 | } 25 | } 26 | } 27 | ?> -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/factory/CountingDuckFactory.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.factory; 2 | 3 | public class CountingDuckFactory extends AbstractDuckFactory { 4 | 5 | public Quackable createMallardDuck() { 6 | return new QuackCounter(new MallardDuck()); 7 | } 8 | 9 | public Quackable createRedheadDuck() { 10 | return new QuackCounter(new RedheadDuck()); 11 | } 12 | 13 | public Quackable createDuckCall() { 14 | return new QuackCounter(new DuckCall()); 15 | } 16 | 17 | public Quackable createRubberDuck() { 18 | return new QuackCounter(new RubberDuck()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/observer/CountingDuckFactory.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.observer; 2 | 3 | public class CountingDuckFactory extends AbstractDuckFactory { 4 | 5 | public Quackable createMallardDuck() { 6 | return new QuackCounter(new MallardDuck()); 7 | } 8 | 9 | public Quackable createRedheadDuck() { 10 | return new QuackCounter(new RedheadDuck()); 11 | } 12 | 13 | public Quackable createDuckCall() { 14 | return new QuackCounter(new DuckCall()); 15 | } 16 | 17 | public Quackable createRubberDuck() { 18 | return new QuackCounter(new RubberDuck()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/factory/pizzas/PizzaTestDrive.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.factory.pizzas; 2 | 3 | public class PizzaTestDrive { 4 | 5 | public static void main(String[] args) { 6 | SimplePizzaFactory factory = new SimplePizzaFactory(); 7 | PizzaStore store = new PizzaStore(factory); 8 | 9 | Pizza pizza = store.orderPizza("cheese"); 10 | System.out.println("We ordered a " + pizza.getName() + "\n"); 11 | System.out.println(pizza); 12 | 13 | pizza = store.orderPizza("veggie"); 14 | System.out.println("We ordered a " + pizza.getName() + "\n"); 15 | System.out.println(pizza); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/TemplateMethod/Barista/CaffeineBeverageWithHook.php: -------------------------------------------------------------------------------- 1 | boilWater(); 5 | $this->brew(); 6 | $this->pourInCup(); 7 | if ($this->customerWantsCondiments()) { 8 | $this->addCondiments(); 9 | } 10 | } 11 | 12 | abstract protected function brew(); 13 | 14 | abstract protected function addCondiments(); 15 | 16 | protected function boilWater() { 17 | println("Boiling water"); 18 | } 19 | 20 | protected function pourInCup() { 21 | println("Pouring into cup"); 22 | } 23 | 24 | protected function customerWantsCondiments() { 25 | return true; 26 | } 27 | } 28 | ?> 29 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/observer/RedheadDuck.php: -------------------------------------------------------------------------------- 1 | observable = new Observable($this); 10 | } 11 | 12 | public function quack() { 13 | println("Quack"); 14 | $this->notifyObservers(); 15 | } 16 | 17 | public function registerObserver(Observer $observer) { 18 | $this->observable->registerObserver($observer); 19 | } 20 | 21 | public function notifyObservers() { 22 | $this->observable->notifyObservers(); 23 | } 24 | 25 | public function __toString() { 26 | return "Redhead Duck"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /weburg/headfirst/combining/observer/RubberDuck.php: -------------------------------------------------------------------------------- 1 | observable = new Observable($this); 10 | } 11 | 12 | public function quack() { 13 | println("Squeak"); 14 | $this->notifyObservers(); 15 | } 16 | 17 | public function registerObserver(Observer $observer) { 18 | $this->observable->registerObserver($observer); 19 | } 20 | 21 | public function notifyObservers() { 22 | $this->observable->notifyObservers(); 23 | } 24 | 25 | public function __toString() { 26 | return "Rubber Duck"; 27 | } 28 | } 29 | ?> -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/composite/CountingDuckFactory.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.composite; 2 | 3 | public class CountingDuckFactory extends AbstractDuckFactory { 4 | 5 | public Quackable createMallardDuck() { 6 | return new QuackCounter(new MallardDuck()); 7 | } 8 | 9 | public Quackable createRedheadDuck() { 10 | return new QuackCounter(new RedheadDuck()); 11 | } 12 | 13 | public Quackable createDuckCall() { 14 | return new QuackCounter(new DuckCall()); 15 | } 16 | 17 | public Quackable createRubberDuck() { 18 | return new QuackCounter(new RubberDuck()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Facade/HomeTheater/TheaterLights.php: -------------------------------------------------------------------------------- 1 | description = $description; 11 | } 12 | 13 | public function on() { 14 | println($this->description . " on"); 15 | } 16 | 17 | public function off() { 18 | println($this->description . " off"); 19 | } 20 | 21 | public function dim($level) { 22 | println($this->description . " dimming to " . $level . "%"); 23 | } 24 | 25 | public function __toString() { 26 | return $this->description; 27 | } 28 | } 29 | ?> -------------------------------------------------------------------------------- /weburg/headfirst/combining/composite/Flock.php: -------------------------------------------------------------------------------- 1 | quackers = new ArrayList(); 12 | } 13 | 14 | public function add(Quackable $quacker) { 15 | $this->quackers->add($quacker); 16 | } 17 | 18 | public function quack() { 19 | $iterator = $this->quackers->iterator(); 20 | while ($iterator->hasNext()) { 21 | $quacker = $iterator->next(); 22 | $quacker->quack(); 23 | } 24 | } 25 | 26 | public function __toString() { 27 | return "Flock of Quackers"; 28 | } 29 | } 30 | ?> -------------------------------------------------------------------------------- /weburg/headfirst/combining/observer/DecoyDuck.php: -------------------------------------------------------------------------------- 1 | observable = new Observable($this); 10 | } 11 | 12 | public function quack() { 13 | println("<< Silence >>"); 14 | $this->notifyObservers(); 15 | } 16 | 17 | public function registerObserver(Observer $observer) { 18 | $this->observable->registerObserver($observer); 19 | } 20 | 21 | public function notifyObservers() { 22 | $this->observable->notifyObservers(); 23 | } 24 | 25 | public function __toString() { 26 | return "Decoy Duck"; 27 | } 28 | } 29 | ?> -------------------------------------------------------------------------------- /weburg/headfirst/combining/observer/MallardDuck.php: -------------------------------------------------------------------------------- 1 | observable = new Observable($this); 10 | } 11 | 12 | public function quack() { 13 | println("Quack"); 14 | $this->notifyObservers(); 15 | } 16 | 17 | public function registerObserver(Observer $observer) { 18 | $this->observable->registerObserver($observer); 19 | } 20 | 21 | public function notifyObservers() { 22 | $this->observable->notifyObservers(); 23 | } 24 | 25 | public function __toString() { 26 | return "Mallard Duck"; 27 | } 28 | } 29 | ?> -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/iterator/dinermerger/ArrayIterator.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.iterator.dinermerger; 2 | 3 | public class ArrayIterator implements Iterator { 4 | MenuItem[] items; 5 | int position = 0; 6 | 7 | public ArrayIterator(MenuItem[] items) { 8 | this.items = items; 9 | } 10 | 11 | public MenuItem next() { 12 | MenuItem menuItem = items[position]; 13 | position = position + 1; 14 | return menuItem; 15 | } 16 | 17 | public boolean hasNext() { 18 | if (position >= items.length || items[position] == null) { 19 | return false; 20 | } else { 21 | return true; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /weburg/headfirst/iterator/dinermerger/ArrayListIterator.php: -------------------------------------------------------------------------------- 1 | items = $items; 13 | } 14 | 15 | public function next() { 16 | $object = $this->items->get($this->position); 17 | $this->position = $this->position + 1; 18 | return $object; 19 | } 20 | 21 | public function hasNext() { 22 | if ($this->position >= $this->items->size()) { 23 | return FALSE; 24 | } else { 25 | return TRUE; 26 | } 27 | } 28 | } 29 | ?> -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/collections/iterator/DinerMenuIterator.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.collections.iterator; 2 | 3 | public class DinerMenuIterator implements Iterator { 4 | String[] items; 5 | int position = 0; 6 | 7 | public DinerMenuIterator(String[] items) { 8 | this.items = items; 9 | } 10 | 11 | public String next() { 12 | String menuItem = items[position]; 13 | position = position + 1; 14 | return menuItem; 15 | } 16 | 17 | public boolean hasNext() { 18 | if (position >= items.length || items[position] == null) { 19 | return false; 20 | } else { 21 | return true; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Decorator/Example1/Beverage/Espresso.php: -------------------------------------------------------------------------------- 1 | machine = $machine; 11 | } 12 | 13 | public function report() { 14 | println("Gumball Machine: " . $this->machine->getLocation()); 15 | println("Current inventory: " . $this->machine->getCount() . " gumballs"); 16 | println("Current state: " . $this->machine->getState()); 17 | } 18 | 19 | // Mimic roughly what Java would output 20 | public function __toString() { 21 | return get_class($this); 22 | } 23 | } 24 | ?> -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/iterator/dinermerger/DinerMenuIterator.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.iterator.dinermerger; 2 | 3 | public class DinerMenuIterator implements Iterator { 4 | MenuItem[] items; 5 | int position = 0; 6 | 7 | public DinerMenuIterator(MenuItem[] items) { 8 | this.items = items; 9 | } 10 | 11 | public MenuItem next() { 12 | MenuItem menuItem = items[position]; 13 | position = position + 1; 14 | return menuItem; 15 | } 16 | 17 | public boolean hasNext() { 18 | if (position >= items.length || items[position] == null) { 19 | return false; 20 | } else { 21 | return true; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /weburg/headfirst/iterator/dinermerger/PancakeHouseMenuIterator.php: -------------------------------------------------------------------------------- 1 | items = $items; 13 | } 14 | 15 | public function next() { 16 | $object = $this->items->get($this->position); 17 | $this->position = $this->position + 1; 18 | return $object; 19 | } 20 | 21 | public function hasNext() { 22 | if ($this->position >= $this->items->size()) { 23 | return FALSE; 24 | } else { 25 | return TRUE; 26 | } 27 | } 28 | } 29 | ?> -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/src/headfirst/designpatterns/combining/observer/DuckCall.java: -------------------------------------------------------------------------------- 1 | package headfirst.designpatterns.combining.observer; 2 | 3 | public class DuckCall implements Quackable { 4 | Observable observable; 5 | 6 | public DuckCall() { 7 | observable = new Observable(this); 8 | } 9 | 10 | public void quack() { 11 | System.out.println("Kwak"); 12 | notifyObservers(); 13 | } 14 | 15 | public void registerObserver(Observer observer) { 16 | observable.registerObserver(observer); 17 | } 18 | 19 | public void notifyObservers() { 20 | observable.notifyObservers(); 21 | } 22 | 23 | public String toString() { 24 | return "Duck Call"; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /java-design-pattern/Head-First-Design-Patterns-master/heatindex.txt: -------------------------------------------------------------------------------- 1 | private float computeHeatIndex(float t, float rh) { 2 | float index = (float)((16.923 + (0.185212 * t) + (5.37941 * rh) - (0.100254 * t * rh) + 3 | (0.00941695 * (t * t)) + (0.00728898 * (rh * rh)) + 4 | (0.000345372 * (t * t * rh)) - (0.000814971 * (t * rh * rh)) + 5 | (0.0000102102 * (t * t * rh * rh)) - (0.000038646 * (t * t * t)) + (0.0000291583 * 6 | (rh * rh * rh)) + (0.00000142721 * (t * t * t * rh)) + 7 | (0.000000197483 * (t * rh * rh * rh)) - (0.0000000218429 * (t * t * t * rh * rh)) + 8 | 0.000000000843296 * (t * t * rh * rh * rh)) - 9 | (0.0000000000481975 * (t * t * t * rh * rh * rh))); 10 | return index; 11 | } 12 | -------------------------------------------------------------------------------- /src/Decorator/Example1/Beverage/DarkRoast.php: -------------------------------------------------------------------------------- 1 |