




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
PAGEPAGE7云南大學(xué)軟件學(xué)院實(shí)驗(yàn)報(bào)告課程:設(shè)計(jì)模式學(xué)期:2012-2013學(xué)年第一學(xué)期任課教師:陸歌浩專業(yè):軟件工程學(xué)號:20101120007姓名:孫金文成績:實(shí)驗(yàn)5抽象工廠模式一、實(shí)驗(yàn)?zāi)康?.熟悉抽象工廠模式2.運(yùn)用抽象工廠模式編制簡單的java程序二、實(shí)驗(yàn)內(nèi)容類圖:實(shí)驗(yàn)代碼:packageabstactFactory.headfirst;publicinterfaceComputerFactory{ publicDisplayaddDisplay(); publicCPUaddCPU(); publicMemoryaddMemory(); publicGraphicsCardaddGraphicsCard(); publicHardDiskaddHardDIsk();}packageabstactFactory.headfirst;publicclassBusinessComputerFactoryimplementsComputerFactory{ publicDisplayaddDisplay(){ returnnewTheOnlyDisplay(); } publicCPUaddCPU(){ returnnewIntelDualCoreProcessorCPU(); } publicMemoryaddMemory(){ returnnewTwoGBMemory(); } publicGraphicsCardaddGraphicsCard(){ returnnewTheOnlyGraphicsCard(); } publicHardDiskaddHardDIsk(){ returnnewFiveHunderedGBHardDisk(); } publicBusinessComputerFactory(){ System.out.println("Thisisabusinesscomputer:"); }}packageabstactFactory.headfirst;publicclassStudentComputerFactoryimplementsComputerFactory{ publicDisplayaddDisplay(){ returnnewTheOnlyDisplay(); } publicCPUaddCPU(){ returnnewAMDDualCoreProcessorCPU(); } publicMemoryaddMemory(){ returnnewOneGBMemory(); } publicGraphicsCardaddGraphicsCard(){ returnnewTheOnlyGraphicsCard(); } publicHardDiskaddHardDIsk(){ returnnewTwoAndHalfHunderedGBHardDisk(); } publicStudentComputerFactory(){ System.out.println("Thisisastudentcomputer:"); }}packageabstactFactory.headfirst;publicclassDeluxeComputerFactoryimplementsComputerFactory{ publicDisplayaddDisplay(){ returnnewTheOnlyDisplay(); } publicCPUaddCPU(){ returnnewIntelFourCoreProcessorCPU(); } publicMemoryaddMemory(){ returnnewEightGBMemory(); } publicGraphicsCardaddGraphicsCard(){ returnnewTheOnlyGraphicsCard(); } publicHardDiskaddHardDIsk(){ returnnewOneTBHardDisk(); } publicDeluxeComputerFactory(){ System.out.println("Thisisadeluxecomputer:"); }}packageabstactFactory.headfirst;publicinterfaceCPU{ Stringcpu=newString();}packageabstactFactory.headfirst;publicclassAMDDualCoreProcessorCPUimplementsCPU{ Stringcpu=newString(); publicAMDDualCoreProcessorCPU(){ cpu="AMDdual-coreprocessor"; System.out.println("cpu:"+cpu); }}packageabstactFactory.headfirst;publicclassIntelDualCoreProcessorCPUimplementsCPU{ Stringcpu=newString(); publicIntelDualCoreProcessorCPU(){ cpu="inteldual-coreprocessor"; System.out.println("cpu:"+cpu); }}packageabstactFactory.headfirst;publicclassIntelFourCoreProcessorCPUimplementsCPU{ Stringcpu=newString(); publicIntelFourCoreProcessorCPU(){ cpu="intelfour-coreprocessor"; System.out.println("cpu:"+cpu); }}packageabstactFactory.headfirst;publicinterfaceMemory{ Stringmemory=newString();}packageabstactFactory.headfirst;publicclassEightGBMemoryimplementsMemory{ Stringmemory=newString(); publicEightGBMemory(){ memory="8GBmemorycard"; System.out.println("memory:"+memory); }}packageabstactFactory.headfirst;publicclassTwoGBMemoryimplementsMemory{ Stringmemory=newString(); publicTwoGBMemory(){ memory="2GBmemorycard"; System.out.println("memory:"+memory); }}packageabstactFactory.headfirst;publicclassOneGBMemoryimplementsMemory{ Stringmemory=newString(); publicOneGBMemory(){ memory="1GBmemorycard"; System.out.println("memory:"+memory); }}packageabstactFactory.headfirst;publicinterfaceHardDisk{ StringhardDisk=newString();}packageabstactFactory.headfirst;publicclassOneTBHardDiskimplementsHardDisk{ StringhardDisk=newString(); publicOneTBHardDisk(){ hardDisk="1TBharddisk"; System.out.println("hardDisk:"+hardDisk); }}packageabstactFactory.headfirst;publicclassFiveHunderedGBHardDiskimplementsHardDisk{ StringhardDisk=newString(); publicFiveHunderedGBHardDisk(){ hardDisk="500GBharddisk"; System.out.println("hardDisk:"+hardDisk); }}packageabstactFactory.headfirst;publicclassTwoAndHalfHunderedGBHardDiskimplementsHardDisk{ StringhardDisk=newString(); publicTwoAndHalfHunderedGBHardDisk(){ hardDisk="250GBharddisk"; System.out.println("hardDisk:"+hardDisk); }}PackageabstactFactory.headfirst;publicinterfaceDisplay{ Stringdisplay=newString();}packageabstactFactory.headfirst;publicclassTheOnlyDisplayimplementsDisplay{ Stringdisplay=newString(); publicTheOnlyDisplay(){ display="SAMSUNG-S22B360HW22inches,16:9"; System.out.println("display:"+display); }}packageabstactFactory.headfirst;publicinterfaceGraphicsCard{ StringgraphicsCard=newString();}packageabstactFactory.headfirst;publicclassTheOnlyGraphicsCardimplementsGraphicsCard{ StringgraphicsCard=newString(); publicTheOnlyGraphicsCard(){ graphicsCard="NVIDIAGeForceGTX550Ti"; System.out.println("graphicsCard:"+graphicsCard); }}packageabstactFactory.headfirst;publicclassComputerStore{ protectedComputerFactorycreateComputer(Stringitem){ ComputerFactorycomputer=null; if(item.equals("Deluxe")){ computer=newDeluxeComputerFactory(); }elseif(item.equals("Business")){ computer=newBusinessComputerFactory(); }elseif(item.equals("Student")){ computer=newStudentComputerFactory(); }elseSystem.out.println("error!"); try{ computer.addCPU(); computer.addMemory(); computer.addHardDIsk(); computer.addDisplay(); computer.addGraphicsCard(); }catch(Exceptione){
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年中國旋轉(zhuǎn)式收納盒行業(yè)市場前景預(yù)測及投資價(jià)值評估分析報(bào)告
- 2025年運(yùn)載火箭發(fā)動機(jī)地面檢測設(shè)備項(xiàng)目規(guī)劃申請報(bào)告
- 安全操控理論題庫及答案
- 2025年鋼筋擠壓連接機(jī)項(xiàng)目市場調(diào)查研究報(bào)告
- 2025年鈉長石塊項(xiàng)目市場調(diào)查研究報(bào)告
- 2025年金屬針布鋼絲抄輥項(xiàng)目市場調(diào)查研究報(bào)告
- 2025年醬燒肉項(xiàng)目市場調(diào)查研究報(bào)告
- 2025年速凍大蒜項(xiàng)目市場調(diào)查研究報(bào)告
- 2025年色彩色差計(jì)項(xiàng)目市場調(diào)查研究報(bào)告
- 2025年熱水袋注水口項(xiàng)目市場調(diào)查研究報(bào)告
- 貨運(yùn)物流提前報(bào)備通知函
- 2025年度山西建設(shè)投資集團(tuán)限公司高校畢業(yè)生招聘885人高頻重點(diǎn)提升(共500題)附帶答案詳解
- 2021-2022年北京市大興區(qū)六年級下冊期末數(shù)學(xué)試卷及答案(人教版)
- 高考高中物理知識點(diǎn)考點(diǎn)框架圖導(dǎo)圖
- 胃食管反流病指南
- 《假如我是患者》課件
- 第三單元+法律與教化+復(fù)習(xí)背誦清單 高二上學(xué)期歷史統(tǒng)編版(2019)選擇性必修1國家制度與社會治理
- 施工機(jī)具安全管理
- 中考數(shù)學(xué)函數(shù)一次函數(shù)復(fù)習(xí)課件
- 擔(dān)保合同范本
- 水電解制氫設(shè)備操作與維護(hù)規(guī)程
評論
0/150
提交評論