publicclassDocumentimplementsFile{privateStringname;publicDocument(Stringname){this.name=name;}publicvoidlist(){System.out.println("Document: "+name);}publicvoidaddFile(Filefile){// do nothing}publicvoidremoveFile(Filefile){// do nothing}}
Design Patterns: Elements of Reusable Object-Oriented Software (ISBN 0-201-63361-2) โดย Erich Gamma, Richard Helm, Ralph Johnson และ John Vlissides (Gang of four: GoF)
แหล่งข้อมูลอื่น
โดย Vince Huston (อังกฤษ)
A look at the Composite design pattern 2013-10-31 ที่ เวย์แบ็กแมชชีน โดย David Geary (อังกฤษ)
ตุลาคม 24, 2021
คอมโพส, ตแพตเท, composite, pattern, เป, นด, ไซน, แพตเท, ดโครงสร, างของอ, อบเจกต, กษณะการทำงานคล, ายก, นและเป, นส, วนประกอบย, อยๆ, ของระบบใหญ, ให, อย, ในร, ปแบบโครงสร, างต, นไม, คลาสผ, ใช, สามารถปฏ, อส, วนต, างๆ, ของคอมโพส, ตในแบบเด, ยวก, นโดยไม, องคำน, งว, าเป. khxmophsitaephtethirn Composite pattern epndiisnaephtethirn thicdokhrngsrangkhxngxxbecktthimilksnakarthangankhlayknaelaepnswnprakxbyxy khxngrabbihyihxyuinrupaebbokhrngsrangtnim khlasphuichsamarthptibtitxswntang khxngkhxmophsitinaebbediywknodyimtxngkhanungwaepnswnplayhruxswnklangkhxngaephnphngtnim twxyangechnokhrngsrangkhxngbthkhwamhnung aebngepnhlay yxhna aetlayxhnayngaebngyxytxipidepnpraoykh kha aelatwxksrinthisud enuxha 1 karnaipichngan 2 twxyangopraekrm 2 1 phasacawa 3 xangxing 4 aehlngkhxmulxunkarnaipichngan aekikhxngkhprakxbkhxngkhxmophsitaephtethirnmisamswnkhux xinetxrefshruxkhlasaebbaexbsaetrkhepnaemaebbthiniyamphvtikrrmthiaetlaxxbecktkhxngkhxmophsittxngmi khlasthisamarthmixngkhprakxbxunkhxngkhxmophsitid khlasthiepnswnplay imsamarthmixngkhprakxbxunid UML khlasidxaaekrmkhxngkhxmophsitaephtethirntwxyangopraekrm aekikhphasacawa aekikh twxyangopraekrmephuxaesdngokhrngsrangkhxng File System odyaebngepnaefmaelaexksarthixyuphayinaefm aelakaraesdngraychuxkhxngaefmaelaexksarphayinxinetxrefs File epnaemaebbkhxngswnprakxbtang khxngkhxmophsit niyamemthxd list ephuxihaetlaxngkhprakxbphimphchuxkhxngtwexngaelaxngkhprakxbyxythixyuphayit public interface File public void list public void addFile File file public void removeFile File file khlas Folder samarthmixxbecktchnid File xun xyuphayitid khuxmiidthng Folder yxyaela Document emthxd list caphimphchuxkhxngtnexngaelatamdwykareriykemthxd list khxngthuk File thixyuphayit Folderemthxd addFile aela removeFile thahnathicdkarkb File yxy phayit Folder public class Folder implements File private String name private ArrayList lt File gt files new ArrayList lt File gt public Folder String name this name name public void addFile File file files add file public void removeFile File file files remove file public void list System out println Folder name for File file files file list khlas Document epnswnplaysudhruxswnyxythisudkhxngkhxmophsit imsamarthmiswnxun phayit dngnnemthxd list cungmihnathiephiyngphimphchuxkhxngtnexngaelaemthxd addFile aela removeFile imtxngthaxair public class Document implements File private String name public Document String name this name name public void list System out println Document name public void addFile File file do nothing public void removeFile File file do nothing kareriykichngan File root new Folder root root addFile new Document one doc File sub new Folder sub sub addFile new Document two doc sub addFile new Document three doc root addFile sub root list xangxing aekikhDesign Patterns Elements of Reusable Object Oriented Software ISBN 0 201 63361 2 ody Erich Gamma Richard Helm Ralph Johnson aela John Vlissides Gang of four GoF aehlngkhxmulxun aekikhComposite ody Vince Huston xngkvs A look at the Composite design pattern Archived 2013 10 31 thi ewyaebkaemchchin ody David Geary xngkvs ekhathungcak https th wikipedia org w index php title khxmophsitaephtethirn amp oldid 9561859, wikipedia, วิกิ หนังสือ, หนังสือ, ห้องสมุด,