



版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、面向?qū)ο蟪绦蛟O(shè)計(jì)實(shí)驗(yàn)指導(dǎo)書宋航劉國奇東北大學(xué)軟件學(xué)院2018.9目 錄面向?qū)ο蟪绦蛟O(shè)計(jì)11/47實(shí)驗(yàn)指導(dǎo)書1前言 2實(shí)驗(yàn)要求3Experiment 1 Implementing the Collections in the Gourmet Coffee System ( 4 Hours )錯(cuò)誤!未定義書簽。Background錯(cuò)誤!未定義書簽。Description錯(cuò)誤!未定義書簽。Files 錯(cuò)誤!未定義書簽。Tasks 錯(cuò)誤!未定義書簽。Experiment 2 Using Design Patterns in the Gourmet Coffee System ( 4 Hours )錯(cuò)誤
2、!未定義書簽。Background錯(cuò)誤!未定義書簽。Description錯(cuò)誤!未定義書簽。Files 錯(cuò)誤!未定義書簽。Tasks 錯(cuò)誤!未定義書簽。Experiment 3 Using File I/O in the Gourmet Coffee System ( 4 Hours )錯(cuò)誤!未定義書簽。Background錯(cuò)誤!未定義書簽。Description錯(cuò)誤!未定義書簽。Files 錯(cuò)誤!未定義書簽。Tasks 錯(cuò)誤!未定義書簽。Experiment 4 Implementing a GUI for the Gourmet Coffee System ( 4 Hours )錯(cuò)誤!未定
3、義書簽。Background錯(cuò)誤!未定義書簽。Description錯(cuò)誤!未定義書簽。Files 錯(cuò)誤!未定義書簽。Tasks 錯(cuò)誤!未定義書簽。前 言面向?qū)ο蟮乃枷肟梢詽B透到需求分析、系統(tǒng)建模、體系結(jié)構(gòu)設(shè)計(jì)、程序設(shè)計(jì)與實(shí)現(xiàn)、系統(tǒng)測(cè)試等多個(gè)方面,它是描述現(xiàn)實(shí)世界復(fù)雜對(duì)象的相當(dāng)直接而且直觀的有效手段,對(duì)于提高系統(tǒng)質(zhì)量、開發(fā)效率和代碼重用率,都有明顯的效果。面向?qū)ο蟪绦蛟O(shè)計(jì)課程是軟件工程專業(yè)的重要專業(yè)基礎(chǔ)課程之一,該門課程注重實(shí)踐性和實(shí)用性,主要通過面向?qū)ο蟪绦蛟O(shè)計(jì)思想和Java語言結(jié)合起來,讓學(xué)生掌握面向?qū)ο蟪绦蛟O(shè)計(jì)思想,以及熟練使用Java語言進(jìn)行面向?qū)ο蟮木幊?,因此學(xué)生不能滿足于只聽懂老師講
4、授的課堂內(nèi)容,看懂書上的程序,應(yīng)將課堂教案與實(shí)踐環(huán)節(jié)緊密結(jié)合,使得學(xué)生加深對(duì)講授內(nèi)容的理解,學(xué)會(huì)上機(jī)調(diào)試程序。也就是善于發(fā)現(xiàn)程序中的錯(cuò)2/47誤,并且能很快地排除這些錯(cuò)誤,使程序能正確運(yùn)行。面向?qū)ο蟪绦蛟O(shè)計(jì)是結(jié)合卡耐基梅隆大學(xué)的SSD3而形成的課程,該課程的教案體系和實(shí)驗(yàn)體系都很完整,并且東北大學(xué)軟件學(xué)院也提供了良好的教案實(shí)驗(yàn)環(huán)境,希望同學(xué)們能夠充分利用實(shí)驗(yàn)條件,認(rèn)真完成實(shí)驗(yàn),從實(shí)驗(yàn)中得到應(yīng)有的鍛煉和培養(yǎng)。希望同學(xué)們?cè)谑褂帽緦?shí)驗(yàn)指導(dǎo)書及進(jìn)行實(shí)驗(yàn)的過程中,能夠幫助我們不斷地發(fā)現(xiàn)問題,并提出建議,使面向?qū)ο蟪绦蛟O(shè)計(jì)真正能夠幫助同學(xué)們學(xué)習(xí)。實(shí)驗(yàn)要求面向?qū)ο蟪绦蛟O(shè)計(jì)課程實(shí)驗(yàn)的目的是為了使學(xué)生在課堂學(xué)習(xí)
5、的同時(shí),通過一系列的實(shí)驗(yàn),使學(xué)生加深了解和更好地掌握面向?qū)ο蟪绦蛟O(shè)計(jì)課程教案大綱要求的內(nèi)容。在面向?qū)ο蟪绦蛟O(shè)計(jì)的課程實(shí)驗(yàn)過程中,要求學(xué)生做到:( 1)預(yù)習(xí)實(shí)驗(yàn)指導(dǎo)書有關(guān)部分,認(rèn)真做好實(shí)驗(yàn)內(nèi)容的準(zhǔn)備,就實(shí)驗(yàn)可能出現(xiàn)的情況提前作出思考和分析。( 2)仔細(xì)觀察調(diào)試程序過程中出現(xiàn)的各種問題,記錄主要問題,作出必要說明和分析。( 3)遵守機(jī)房紀(jì)律,服從輔導(dǎo)教師指揮,愛護(hù)實(shí)驗(yàn)設(shè)備。3/47( 4)實(shí)驗(yàn)課程不遲到,如有事不能出席,所缺實(shí)驗(yàn)一般不補(bǔ)。( 5)本實(shí)驗(yàn)采用的開發(fā)環(huán)境為 Eclipse ,同學(xué)在做實(shí)驗(yàn)之前要求熟悉該集成開發(fā)環(huán)境。Experiment1ImplementingtheGourmetCof
6、feeSystem(4 Hours)Prerequisites, Goals, and OutcomesPrerequisites:Before you begin this exercise, you need mastery of the following:Object Oriented Programmingo Knowledge of class designClass attributesConstructorsAccessor methodsMutator methodso Knowledge of inheritanceHow to implement a specializa
7、tion/generalizationrelationship using inheritanceGoals:Reinforce your ability to implement Java classes using inheritance.Outcomes:You will demonstrate mastery of the following:Implementing the constructors, accessors, and mutators of a Java classUsing inheritance to implement a specialization/gener
8、alization relationshipBackgroundThis assignment asks you to implement some of the classes in theGourmet Coffee Systemspecified on Exercise 2.DescriptionIn this assessment, you will implement the classes and relationships illustrated in the following class diagram:4/47Figure 1Portion of Gourmet Coffe
9、e System class diagramThe class specifications are as follows:ClassProductThe classProduct models a generic product in the store.Instance variables:code. The unique code that identifies the productdescription. A short description of the productprice . The price of the productConstructor and methods:
10、public Product(String initialCode,String initialDescription,double initialPrice)Constructor that initializes the instance variablescode, description, andprice .5/47public String getCode(). Returns the value of instance variablecode.public String getDescription(). Returns the value of instance variab
11、ledescription.public double getPrice(). Returns the value of instance variableprice .boolean equals(Object object). Overrides the methodequals in the classObject . Two Product objects are equal if their codes are equal.String toString(). Overrides the methodtoStringReturns the string representation
12、of aProduct object. Thethe following format:code_description_pricein the class Object . String returned hasThe fields are separated by an underscore (_ ). You can assume that the fieldsthemselves do not contain any underscores.ClassCoffeeThe classCoffee models a coffee product. It extends classProdu
13、ct .Instance variables:origin. The origin of the coffeeroast . The roast of the coffeeflavor. The flavor of the coffeearoma. The aroma of the coffeeacidity. The acidity of the coffeebody. The body of the coffeeConstructor and methods:public Coffee(String initialCode,String initialDescription,double
14、initialPrice,String initialOrigin,String initialRoast,String initialFlavor,String initialAroma,String initialAcidity,String initialBody)Constructor that initializes the instance variablescode, description, price ,origin, roast , flavor, aroma, acidity, andbody.6/47public String getOrigin(). Returns
15、the value of instance variableorigin.public String getRoast(). Returns the value of instance variableroast .public String getFlavor(). Returns the value of instance variableflavor.public String getAroma(). Returns the value of instance variablearoma.public String getAcidity(). Returns the value of i
16、nstance variableacidity .public String getBody(). Returns the value of instance variableString toString(). Overrides the methodtoStringin the classReturns the string representation of aCoffeeobject. TheStringthe following format:body.Object .returned hascode_description_price _origin_roast _flavor_a
17、roma_acidity_bodyThe fields are separated by an underscore (_ ). You can assume that the fieldsthemselves do not contain any underscores.ClassCoffeeBrewerClass CoffeeBrewer models a coffee brewer. It extends classProduct .Instance variables:model. The model of the coffee brewerwaterSupply . The wate
18、r supply (Pour-over or Automatic )numberOfCups. The capacity of the coffee brewerConstructor and methods:public CoffeeBrewer(String initialCode,String initialDescription,double initialPrice,String initialModel,String initialWaterSupply,int initialNumberOfCups)Constructor that initializes the instanc
19、e variablescode description,price, and.model waterSupplynumberOfCupspublic String getModel(). Returns the value of instance variablemodel.7/47public String getWaterSupply(). Returns the value of instance variablewaterSupply .public int getNumberOfCups(). Returns the value of instance variablenumberO
20、fCups.String toString(). Overrides the methodtoStringin the classObject .Returns the string representation of aCoffeeBrewer object. TheStringreturned has the following format:code_description_price _model_waterSupply _numberOfCupsThe fields are separated by an underscore (_ ). You can assume that th
21、e fieldsthemselves do not contain any underscores.ClassOrderItemClass OrderItem models an item in an order.Instance variables:product . This instance variable represents the one-way association betweenOrderItem and Product . It contains a reference to aProduct object.quantity. The quantity of the pr
22、oduct in the order.Constructor and methods:public OrderItem(Product initialProduct,int initialQuantity)Constructor that initializes the instance variablesproduct and quantity .public Product getProduct(). Returns the value of the instance variableproduct , a reference to aProduct object.public int g
23、etQuantity(). Returns the value of the instance variablequantity .public void setQuantity(int newQuantity). Sets the instance variablequantityto the value of parameternewQuantity .public double getValue(). Returns the product ofquantity and price .8/47String toString(). Overrides the methodtoStringi
24、n the classObject .Returns the string representation of anOrderItem object. TheStringrepresentation has the following format:quantityproduct-codeproduct-priceThe fields are separated by a space. You can assume that the fields themselves do not contain any spaces.Test driver classesComplete implement
25、ations of the following test drivers are provided in the student archive.Use these test drivers to verify that your code works correctly.ClassClassClassClassTestProductTestCoffeeTestCoffeeBrewerTestOrderItemFilesThe following files are needed to complete this assignment:student-files.zip Download th
26、is file. This archive contains the following:o TestProduct.javao TestCoffee.javao TestCoffeeBrewer.java o TestOrderItem.javaTasksImplement classesProduct , Coffee , CoffeeBrewer , andOrderItem . Document usingJavadoc and follow Sun's code conventions. The following steps will guide you through t
27、hisassignment. Work incrementally and test each increment. Save often.1.Extractthe files by issuing the following command at the command prompt:C:>unzip student-files.zip2.Then , implement classProduct from scratch.UseTestProduct driver to testyour implementation.3.Next , implement classCoffee fr
28、om scratch.UseTestCoffee driver to test yourimplementation.9/474.Then, implement classCoffeeBrewer from scratch. UseTestCoffeeBrewerdriver to test your implementation.5.Finally, implement classOrderItem from scratch. UseTestOrderItem driver totest your implementation.SubmissionUpon completion, submi
29、tonlythe following:1. Product.java2. Coffee.java3. CoffeeBrewer.java4. OrderItem.javaExperiment2ImplementingtheCollectionsintheGourmet Coffee System (4 Hours)Prerequisites, Goals, and OutcomesPrerequisites:Before you begin this exercise, you need mastery of the following:CollectionsoUse of classArra
30、yListo Use of iteratorsGoals:Reinforce your ability to implement classes that use collectionsOutcomes:You will demonstrate mastery of the following:Implementing a Java class that uses collectionsBackgroundIn this assignment, you will implement the classes in theGourmet Coffee Systemthat usecollectio
31、ns.DescriptionThe following class diagram of theGourmet Coffee Systemhighlights the classes that usecollections:10/47Figure 2 Gourmet Coffee System class diagramComplete implementations of the following classes are provided in the student archive:CoffeeCoffeeBrewerProductOrderItemGourmetCoffeeIn thi
32、s assignment, you will implement the following classes:CatalogOrderSalesGourmetCoffee11/47The class specifications are as follows:ClassCatalogThe classCatalog models a product catalog. This class implements the interfaceIterable<Product> to being able to iterate through the products using thef
33、or-eachloop.Instance variables:products AnArrayListcollection that contains references to instances ofclass Product .Constructor and public methods:public Catalog() Creates the collectionproducts, which is initially empty.public void addProduct(Product product) Adds the specified productto the colle
34、ctionproducts.public Iterator<Product> iterator() Returns an iterator over theinstances in the collectionproducts .public Product getProduct(String code) Returns a reference to theProduct instance with the specified code. Returnsnullif there are no productsin the catalog with the specified cod
35、e.public int getNumberOfProducts() Returns the number of instances inthe collectionproducts .ClassOrderThe classOrder maintains a list of order items. This class implements the interfaceIterable<OrderItem>to being able to iterate through the items using thefor-eachloop.Instance variables:items
36、 An ArrayListcollection that contains references to instances of classOrderItem .Constructor and public methods:public Order() Creates the collectionitems , which is initially empty.12/47public void addItem(OrderItem orderItem) Adds the specified orderitem to the collectionitems .public void removeI
37、tem(OrderItem orderItem) Removes the specifiedorder item from the collectionitems .public Iterator<OrderItem> iterator() Returns an iterator over theinstances in the collectionitems .public OrderItem getItem(Product product) Returns a reference totheOrderItem instance with the specified produc
38、t. Returnsnull if there are noitems in the order with the specified product.public int getNumberOfItems() Returns the number of instances in thecollectionitems .public double getTotalCost() Returns the total cost of the order.ClassSalesThe classSales maintains a list of the orders that have been com
39、pleted. This classimplements the interfaceIterable<Order>to being able to iterate through the ordersusing thefor-eachloop.Instance variables:orders An ArrayListcollection that contains references to instances of classOrder .Constructor and public methods:public Sales() Creates the collectionor
40、ders , which is initially empty.public void addOrder(Order order) Adds the specified order to thecollectionorders .public Iterator<Order> iterator() Returns an iterator over theinstances in the collectionorders .public int getNumberOfOrders() Returns the number of instances in thecollectionord
41、ers .ClassGourmetCoffeeThe class GourmetCoffee creates a console interface to process store orders. Currently, it includes the complete implementation of some of the methods. The methods13/47public void addModifyProduct()displayNumberOfOrders and displayTotalQuantityOfProductsare incompleteand shoul
42、d be implemented. The following is a screen shot of the interface:Figure 3 Execution of GourmetCoffeeInstance variables:catalog A Catalog object with the products that can be sold.currentOrder An Order object with the information about the current order.sales A Sales object with information about al
43、l the orders sold by the store.Constructor and public methods:public GourmetCoffeeSolution() Initializes the attributescatalog ,currentOrder and sales . This constructor is complete and should not bemodified.public void displayCatalog Displays the catalog. This method iscomplete and should not be mo
44、dified.public void displayProductInfo() Prompts the user for a product codeand displays information about the specified product. This method is complete and should not be modified.public void displayOrder() Displays the products in the current order.This method is complete and should not be modified
45、. Prompts the user for a product code andquantity. If the specified product is not already part of the order, it is added。otherwise, the quantity of the product is updated. This method is complete andshould not be modified.public void removeProduct() Prompts the user for a product code andremoves th
46、e specified product from the current order. This method is complete and should not be modified.14/47public void saleOrder() Registers the sale of the current order. Thismethod is complete and should not be modified.public void displayOrdersSold() Displays the orders that have beensold. This method i
47、s complete and should not be modified.public void displayNumberOfOrders(Product product) Displays thenumber of orders that contain the specified product. This method is incompleteand should be implemented.public void displayTotalQuantityOfProducts() Displays the totalquantity sold for each product i
48、n the catalog. This method is incomplete and should be implemented.Test driver classesComplete implementations of the following test drivers are provided in the student archive:ClassClassClassTestCatalogTestOrderTestSalesFilesThe following files are needed to complete this assignment:student-files.z
49、ip Download this file. This archive contains the following:o Class filesCoffee.classCoffeeBrewer.classProduct.classOrderItem.classo DocumentationCoffee.htmlCoffeeBrewer.htmlProduct.htmlOrderItem.htmlo Java filesGourmetCoffee.java An incomplete implementation.TestCatalog.java A complete implementation.TestOrder.java A complete implement
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- AI技術(shù)助力精準(zhǔn)醫(yī)療的倫理與法律考量
- 健康管理的未來基于醫(yī)療大數(shù)據(jù)的預(yù)測(cè)與決策支持
- 企業(yè)商業(yè)決策與醫(yī)療健康A(chǔ)PP用戶隱私保護(hù)的平衡
- 健康教育中的預(yù)防意識(shí)培養(yǎng)與傳播
- 從傳統(tǒng)到數(shù)字醫(yī)療健康行業(yè)的轉(zhuǎn)型之路
- 從數(shù)據(jù)看變化醫(yī)療科技類應(yīng)用如何影響我們的生活習(xí)慣
- 全球視角下的區(qū)塊鏈技術(shù)未來趨勢(shì)研究
- 臨床研究中的實(shí)驗(yàn)數(shù)據(jù)隱私保護(hù)措施探討
- 以創(chuàng)新引領(lǐng)未來-基于區(qū)塊鏈技術(shù)的教育行業(yè)供應(yīng)鏈管理方案研究
- 健康信息技術(shù)的倫理影響與展望
- 預(yù)制菜烹飪知識(shí)培訓(xùn)課件
- 教學(xué)設(shè)計(jì)-3.7函數(shù)圖形的描繪
- 《數(shù)字資源利用》課件
- 《馬達(dá)保護(hù)器培訓(xùn)》課件
- 消防安全重點(diǎn)單位管理
- 2025年度花崗巖墓碑石材采購合同范本
- 《止血與包扎》課件
- 2025年水稻種植農(nóng)戶互助合作合同3篇
- 2024員工三級(jí)安全培訓(xùn)考試題含答案(能力提升)
- Unit 9 Active learning 說課稿-2023-2024學(xué)年高中英語北師大版(2019)必修第三冊(cè)
- 中央空調(diào)施工工藝空調(diào)施工95課件講解
評(píng)論
0/150
提交評(píng)論