b'\n_START_ARTICLE_\nGy\xc3\xa1rt\xc3\xb3 met\xc3\xb3dus programtervez\xc3\xa9si minta\n_START_SECTION_\nP\xc3\xa9lda\n_START_PARAGRAPH_\nA p\xc3\xa9lda egy labirintusj\xc3\xa1t\xc3\xa9k, ami tartalmaz norm\xc3\xa1l \xc3\xa9s elvar\xc3\xa1zsolt szob\xc3\xa1kat. A program l\xc3\xa9tre tud hozni norm\xc3\xa1l \xc3\xa9s elvar\xc3\xa1zsolt labirintusokat is. A j\xc3\xa1t\xc3\xa9k szerkezete:_NEWLINE_A Room a term\xc3\xa9kek (MagicRoom, OrdinaryRoom) k\xc3\xb6z\xc3\xb6s \xc3\xa1ltal\xc3\xa1nos\xc3\xadt\xc3\xa1sa. A MazeGame egy absztrakt gy\xc3\xa1rt\xc3\xb3 met\xc3\xb3dust tartalmaz, ami ilyen term\xc3\xa9ket gy\xc3\xa1rt. A MagicRoom \xc3\xa9s az OrdinaryRoom implement\xc3\xa1lj\xc3\xa1k a megfelel\xc5\x91 term\xc3\xa9keket, m\xc3\xadg a MagicMazeGame \xc3\xa9s az OrdinaryMazeGame a MazeGame gyerekeik\xc3\xa9nt az ott deklar\xc3\xa1lt gy\xc3\xa1rt\xc3\xb3 met\xc3\xb3dust val\xc3\xb3s\xc3\xadtj\xc3\xa1k meg. Ezzel \xc3\xa1tveszik a h\xc3\xadv\xc3\xb3t a konkr\xc3\xa9t oszt\xc3\xa1lyok implement\xc3\xa1ci\xc3\xb3j\xc3\xa1b\xc3\xb3l. Ezzel feleslegess\xc3\xa9 v\xc3\xa1lik a new oper\xc3\xa1tor, lehet\xc5\x91v\xc3\xa9 v\xc3\xa1lik a ny\xc3\xadlt/z\xc3\xa1rt elv alkalmaz\xc3\xa1sa, \xc3\xa9s a v\xc3\xa9gterm\xc3\xa9\xc3\xa9k rugalmasabban viselkediok a fut\xc3\xa1sidej\xc5\xb1 v\xc3\xa1ltoz\xc3\xa1sokkal szemben.\n_START_SECTION_\nJava\n_START_PARAGRAPH_\nAz al\xc3\xa1bbi Java k\xc3\xb3dok a fenti labirintus (MazeGame) r\xc3\xa9szleteit mutatj\xc3\xa1k be. A norm\xc3\xa1l szob\xc3\xa1kb\xc3\xb3l csak a szomsz\xc3\xa9d szob\xc3\xa1kba lehet \xc3\xa1tmenni, m\xc3\xadg az elvar\xc3\xa1zsolt szob\xc3\xa1kb\xc3\xb3l v\xc3\xa9letlenszer\xc5\xb1en lehet teleport\xc3\xa1lni. A MazeGame ezek k\xc3\xb6z\xc3\xb6s \xc3\xa1ltal\xc3\xa1nos\xc3\xadt\xc3\xa1s\xc3\xa1t, a Room-okat haszn\xc3\xa1lja, de a pontos megval\xc3\xb3s\xc3\xadt\xc3\xa1st ut\xc3\xb3daira hagyja._NEWLINE_public abstract class MazeGame {_NEWLINE_    private final List<Room> rooms = new ArrayList<>();_NEWLINE__NEWLINE_    public MazeGame() {_NEWLINE_        Room room1 = makeRoom();_NEWLINE_        Room room2 = makeRoom();_NEWLINE_        room1.connect(room2);_NEWLINE_        rooms.add(room1);_NEWLINE_        rooms.add(room2);_NEWLINE_    }_NEWLINE__NEWLINE_    abstract protected Room makeRoom();}_NEWLINE_A fenti k\xc3\xb3dszakaszban a MazeGame konstruktora sablonf\xc3\xbcggv\xc3\xa9nyk\xc3\xa9nt van megval\xc3\xb3s\xc3\xadtva, \xc3\xa9s k\xc3\xb6z\xc3\xb6s logik\xc3\xa1t foglal mag\xc3\xa1ba. Hivatkozik a makeRoom gy\xc3\xa1rt\xc3\xb3 met\xc3\xb3dusra, ami mag\xc3\xa1ba foglalja a szob\xc3\xa1k l\xc3\xa9trehoz\xc3\xa1s\xc3\xa1t, \xc3\xadgy m\xc3\xa1s szob\xc3\xa1k haszn\xc3\xa1lhat\xc3\xb3k aloszt\xc3\xa1lyban. Egy m\xc3\xa1sik j\xc3\xa1t\xc3\xa9k met\xc3\xb3dushoz el\xc3\xa9g fel\xc3\xbcl\xc3\xadrni a makeRoom met\xc3\xb3dust:_NEWLINE_public class MagicMazeGame extends MazeGame {_NEWLINE_    @Override_NEWLINE_    protected Room makeRoom() {_NEWLINE_        return new MagicRoom();_NEWLINE_    }}public class OrdinaryMazeGame extends MazeGame {_NEWLINE_    @Override_NEWLINE_    protected Room makeRoom() {_NEWLINE_        return new OrdinaryRoom();_NEWLINE_    }}MazeGame ordinaryGame = new OrdinaryMazeGame();MazeGame magicGame = new MagicMazeGame();\n_START_SECTION_\nPHP\n_START_PARAGRAPH_\nAz al\xc3\xa1bbi PHP p\xc3\xa9lda azt mutatja, hogy a term\xc3\xa9kek a lesz\xc3\xa1rmaz\xc3\xa1s helyett meg is val\xc3\xb3s\xc3\xadthatnak egy interf\xc3\xa9szt, a gy\xc3\xa1rt\xc3\xb3 met\xc3\xb3dus pedig publikus lehet, \xc3\xa9s a kliens k\xc3\xb6zvetlen\xc3\xbcl is h\xc3\xadvhatja:_NEWLINE_/* Factory and car interfaces */interface CarFactory{_NEWLINE_    public function makeCar();}interface Car{_NEWLINE_    public function getType();}/* Concrete implementations of the factory and car */class SedanFactory implements CarFactory{_NEWLINE_    public function makeCar()_NEWLINE_    {_NEWLINE_        return new Sedan();_NEWLINE_    }}class Sedan implements Car{_NEWLINE_    public function getType()_NEWLINE_    {_NEWLINE_        return \'Sedan\';_NEWLINE_    }}/* Client */$factory = new SedanFactory();$car = $factory->makeCar();print $car->getType();\n_START_SECTION_\nC#\n_START_PARAGRAPH_\nusing System;namespace Factory_Method {_NEWLINE_abstract class MinositesGyar {_NEWLINE_public Minosites createMinosites() {_NEWLINE_// itt a gy\xc3\xa1rt\xc3\xa1s el\xc5\x91tt lehet ezt-azt csin\xc3\xa1lni, pl. logolni_NEWLINE_return Minosit();_NEWLINE_}_NEWLINE_public abstract Minosites Minosit();_NEWLINE_}_NEWLINE_class KonkretMinositesGyar1: MinositesGyar {_NEWLINE_public override Minosites Minosit() {_NEWLINE_return new A_Minosites();_NEWLINE_}_NEWLINE_}_NEWLINE_class KonkretMinositesGyar2: MinositesGyar {_NEWLINE_public override Minosites Minosit() {_NEWLINE_return new B_Minosites();_NEWLINE_}_NEWLINE_}_NEWLINE_interface Minosites {_NEWLINE_void Minosit();_NEWLINE_}_NEWLINE_class A_Minosites: Minosites {_NEWLINE_public void Minosit() {_NEWLINE_Console.WriteLine("A-min\xc5\x91s\xc3\xadt\xc3\xa9sben r\xc3\xa9szes\xc3\xbcl!");_NEWLINE_}_NEWLINE_}_NEWLINE_class B_Minosites: Minosites {_NEWLINE_public void Minosit() {_NEWLINE_Console.WriteLine("B-min\xc5\x91s\xc3\xadt\xc3\xa9sben r\xc3\xa9szes\xc3\xbcl!");_NEWLINE_}_NEWLINE_}_NEWLINE_class Program {_NEWLINE_static void Main(string[] args) {_NEWLINE_MinositesGyar[] minosito = new MinositesGyar[2];_NEWLINE_minosito[0] = new KonkretMinositesGyar1();_NEWLINE_minosito[1] = new KonkretMinositesGyar2();_NEWLINE_foreach(MinositesGyar m in minosito) {_NEWLINE_Minosites min = m.Minosit();_NEWLINE_min.Minosit();_NEWLINE_}_NEWLINE_Console.ReadLine();_NEWLINE_}_NEWLINE_}}\n_START_SECTION_\nFord\xc3\xadt\xc3\xa1s\n_START_PARAGRAPH_\nEz a sz\xc3\xb3cikk r\xc3\xa9szben vagy eg\xc3\xa9szben  a   Factory method pattern c\xc3\xadm\xc5\xb1 angol Wikip\xc3\xa9dia-sz\xc3\xb3cikk ford\xc3\xadt\xc3\xa1s\xc3\xa1n alapul.  Az eredeti cikk szerkeszt\xc5\x91it annak lapt\xc3\xb6rt\xc3\xa9nete sorolja fel.'