C建造者模式和示例代碼.doc

C建造者模式和示例代碼.doc

ID:59256014

大小:282.00 KB

頁(yè)數(shù):7頁(yè)

時(shí)間:2020-09-08

C建造者模式和示例代碼.doc_第1頁(yè)
C建造者模式和示例代碼.doc_第2頁(yè)
C建造者模式和示例代碼.doc_第3頁(yè)
C建造者模式和示例代碼.doc_第4頁(yè)
C建造者模式和示例代碼.doc_第5頁(yè)
資源描述:

《C建造者模式和示例代碼.doc》由會(huì)員上傳分享,免費(fèi)在線(xiàn)閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)

1、模式設(shè)計(jì)c#--創(chuàng)建型--Builder名稱(chēng)Builder建造者模式結(jié)構(gòu)意圖將一個(gè)復(fù)雜對(duì)象的構(gòu)建與它的表示分離,使得同樣的構(gòu)建過(guò)程可以創(chuàng)建不同的表示。適用性·當(dāng)創(chuàng)建復(fù)雜對(duì)象的算法應(yīng)該獨(dú)立于該對(duì)象的組成部分以及它們的裝配方式時(shí)?!ぎ?dāng)構(gòu)造過(guò)程必須允許被構(gòu)造的對(duì)象有不同的表示時(shí)。CodeExamplenamespace?Builder_DesignPattern{????using?System;????//?These?two?classes?could?be?part?of?a?framework,????//?which?we?will?call?DP???

2、?//?===============================================????????class?Director?????{????????public?void?Construct(AbstractBuilder?abstractBuilder)????????{????????????abstractBuilder.BuildPartA();????????????if?(1==1?)?//represents?some?local?decision?inside?director????????????{???????

3、?????????abstractBuilder.BuildPartB();????????????????????????}????????????abstractBuilder.BuildPartC();????????????????????}????}????abstract?class?AbstractBuilder?????{????????abstract?public?void?BuildPartA();????????abstract?public?void?BuildPartB();????????abstract?public?void

4、?BuildPartC();????}????//?These?two?classes?could?be?part?of?an?application?????//?=================================================????class?ConcreteBuilder?:?AbstractBuilder?????{????????override?public?void?BuildPartA()????????{????????????//?Create?some?object?here?known?to?Con

5、creteBuilder????????????Console.WriteLine("ConcreteBuilder.BuildPartA?called");????????}????????????????????????override?public?void?BuildPartB()????????{????????????//?Create?some?object?here?known?to?ConcreteBuilder????????????Console.WriteLine("ConcreteBuilder.BuildPartB?called"

6、);????????}????????????????override?public?void?BuildPartC()????????{????????????//?Create?some?object?here?known?to?ConcreteBuilder????????????Console.WriteLine("ConcreteBuilder.BuildPartC?called");????????}????}????????///?

????///????Summary?description?for?Client.????//

7、/?

????public?class?Client????{????????public?static?int?Main(string[]?args)????????{????????????ConcreteBuilder?concreteBuilder?=?new?ConcreteBuilder();????????????Director?director?=?new?Director();????????????director.Construct(concreteBuilder);????????????return?0;????

8、????}????}}一、?建造者(Builder)

當(dāng)前文檔最多預(yù)覽五頁(yè),下載文檔查看全文

此文檔下載收益歸作者所有

當(dāng)前文檔最多預(yù)覽五頁(yè),下載文檔查看全文
溫馨提示:
1. 部分包含數(shù)學(xué)公式或PPT動(dòng)畫(huà)的文件,查看預(yù)覽時(shí)可能會(huì)顯示錯(cuò)亂或異常,文件下載后無(wú)此問(wèn)題,請(qǐng)放心下載。
2. 本文檔由用戶(hù)上傳,版權(quán)歸屬用戶(hù),天天文庫(kù)負(fù)責(zé)整理代發(fā)布。如果您對(duì)本文檔版權(quán)有爭(zhēng)議請(qǐng)及時(shí)聯(lián)系客服。
3. 下載前請(qǐng)仔細(xì)閱讀文檔內(nèi)容,確認(rèn)文檔內(nèi)容符合您的需求后進(jìn)行下載,若出現(xiàn)內(nèi)容與標(biāo)題不符可向本站投訴處理。
4. 下載文檔時(shí)可能由于網(wǎng)絡(luò)波動(dòng)等原因無(wú)法下載或下載錯(cuò)誤,付費(fèi)完成后未能成功下載的用戶(hù)請(qǐng)聯(lián)系客服處理。