版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、面向?qū)ο蟪绦蛟O計實驗指導書宋航 劉國奇東北大學軟件學院2012.9目錄面向?qū)ο蟪绦蛟O計 1實驗指導書 1前 言 3實驗要求 4Experiment 1 Implementing the Collections in the Gourmet Coffee System (4 Hours ) 錯誤!未定義書簽。Background 錯誤!未定義書簽。Description 錯誤!未定義書簽。Files 錯誤!未定義書簽。Tasks 錯誤!未定義書簽。Experiment 2 Using Design Patterns in the Gourmet Coffee System (4 Hours) 錯
2、誤!未定 義書簽。Background 錯誤!未定義書簽。Description 錯誤!未定義書簽。Files 錯誤!未定義書簽。Tasks 錯誤!未定義書簽。Experiment 3 Using File I/O in the Gourmet Coffee System (4 Hours )錯誤!未定義書簽。Background 錯誤!未定義書簽。Description 錯誤!未定義書簽。Files 錯誤!未定義書簽。Tasks 錯誤!未定義書簽。Experiment 4 Implementing a GUI for the Gourmet Coffee System (4 Hours )錯
3、誤!未定義 書簽。Background 錯誤!未定義書簽。Description 錯誤!未定義書簽。Files 錯誤!未定義書簽。Tasks 錯誤!未定義書簽。、八前言面向?qū)ο蟮乃枷肟梢詽B透到需求分析、系統(tǒng)建模、 體系結(jié)構設計、 程序設計與實現(xiàn)、系 統(tǒng)測試等多個方面, 它是描述現(xiàn)實世界復雜對象的相當直接而且直觀的有效手段, 對于提高 系統(tǒng)質(zhì)量、開發(fā)效率和代碼重用率,都有明顯的效果。面向?qū)ο蟪绦蛟O計課程是 軟件工程專業(yè)的重要專業(yè)基礎課程之一,該門課程注 重實踐性和實用性,主要通過面向?qū)ο蟪绦蛟O計思想和 Java語言結(jié)合起來,讓學生掌握 面向?qū)ο蟪绦蛟O計思想,以及熟練使用 Java語言進行面向?qū)ο?/p>
4、的編程,因此學生不能滿 足于只聽懂老師講授的課堂內(nèi)容,看懂書上的程序,應將 課堂教學與實踐環(huán)節(jié)緊密結(jié)合, 使得學生加深對講授內(nèi)容的理解, 學會上機調(diào)試程序。 也就是善于發(fā)現(xiàn)程序中的錯誤, 并且 能很快地排除這些錯誤,使程序能正確運行。面向?qū)ο蟪绦蛟O計是結(jié)合卡耐基梅隆大學的SSD3而形成的課程,該課程的教學體系和實驗體系都很完整, 并且東北大學軟件學院也 提供了良好的教學實驗環(huán)境, 希望同學 們能夠充分利用實驗條件,認真完成實驗,從實驗中得到應有的鍛煉和培養(yǎng)。希望同學們在使用本實驗指導書及進行實驗的過程中, 能夠幫助我們不斷地發(fā)現(xiàn)問 題,并提出建議,使 面向?qū)ο蟪绦蛟O計 真正能夠幫助同學們學習實
5、驗要求面向?qū)ο蟪绦蛟O計課程實驗的目的是為了使學生在課堂學習的同時,通過一系 列的實驗,使學生加深了解和更好地掌握面向?qū)ο蟪绦蛟O計課程教學大綱要求的內(nèi) 容。在面向?qū)ο蟪绦蛟O計的課程實驗過程中,要求學生做到:(1)預習實驗指導書有關部分,認真做好實驗內(nèi)容的準備,就實驗可能出現(xiàn)的情 況提前作出思考和分析。(2)仔細觀察調(diào)試程序過程中出現(xiàn)的各種問題,記錄主要問題,作出必要說明和 分析。(3)遵守機房紀律,服從輔導教師指揮,愛護實驗設備。(4)實驗課程不遲到,如有事不能出席,所缺實驗一般不補。( 5)本實驗采用的開發(fā)環(huán)境為 Eclipse ,同學在做實驗之前要求熟悉該集成開發(fā)環(huán) 境。Experiment
6、 1 Implementing the Gourmet CoffeeSystem(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 in
7、heritanceHow to implement a specialization/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 class« Using
8、 inheritance to implement a specialization/generalization relationshipBackgro undThis assignment asks you to implement some of the classes in theGourmet Coffee Systemspecified on Exercise 2.Descriptio nIn this assessment, you will implement the classes and relationships illustrated in the following
9、class diagram:Product-pnoductcod電:Slnng-description: String-price : doubte+et Q>deO ; String+gst Q&gaiptioriO : String+get PnceQ : double+equ3l50bject Object) bcdeanrtoSlringQ : Stringncfrltem-quantity: irft -etProductO: Product -etQuantt-iO : int +setQij3ntity(neud Oij®rrtir0nl) +getlii
10、eO: double-rtoStringQ:: SwingCoffeeorigin : String -roast: Stnng 七詢r :沏叩aroma : String -acidity: String body: String +get DriginQ: String +gst Rc*astO : String +get AawrQ : String +getArorraO :+get陽dit肉:Stting +get BodyQ ; Siring-He StringQ : StringCo Ifee Bremer model: String -wterSupply:String -nu
11、mberOfCups : irvt hgetM&delO : String -tWrterSupIyO : String +«thLmberOfCupsQ : int 4to$1rihg0 : StringFigure 1Porti on of Gourmet Coffee System class diagramThe class specifications are as follows:Class ProductThe class Product models a generic product in the store.Instance variables:* cod
12、e. The unique code that identifies the product* descripti on . A short description of the product* price . The price of the productConstructor and methods:* public Product(Stri ng in itialCode,* String in itialDescripti on,* double in itialPrice)Constructor that initializes the instance variablescod
13、e, descripti on ,and pricecode.« public String getCode().Returns the value of instance variable« public String getDescripti on(). Returns the value of instance variabledescripti on public double getPrice() . Returns the value of instance variableprice .« boolean equalS(Object object)
14、. Overrides the method equals in the class Object . Two Product objects are equal if their codes are equal.* String toString(). Overrides the methodtoStringin the class Object.Returns the string representation of aProduct object. The Stri ng returned has thefollowing format:code_descripti on _priceT
15、he fields are separated by an underscore ( themselves do not contain any underscores.).You can assume that the fieldsClass CoffeeThe class Coffee models a coffee product. It extends classProduct.Instance variables:origi n . The origin of the coffee« roast . The roast of the coffee« flavor
16、. The flavor of the coffee«aroma. The aroma of the coffee* acidity . The acidity of the coffee«body. The body of the coffeeConstructor and methods:public Coffee(Stri ng in itialCode,Stri ng in itialDescriptio n, double in itialPrice,Stri ng in itialOrigi n, String in itialRoast,String init
17、ialFlavor,Stri ng in itialAroma,Stri ng in itialAcidity,Stri ng in itialBody)Constructor that initializes the instance variables origin , roast , flavor , aroma aciditycode, description , price ,and body.public Stri ng getOrigi n(). Returns the value of instance variableorigi npublic String getRoast
18、(). Returns the value of instance variableroast .public String getFlavor(). Returns the value of instance variableflavorpublic Stri ng getAroma(). Returns the value of instance variablearomapublic String getAcidityO . Returns the value of instance variableaciditypublic String getBody() . Returns the
19、 value of instance variablebody.in the class Object.Stri ng returned has theStri ng toStri ng(). Overrides the method toStri ngReturns the string representation of aCoffee object. Thefollowing format:code_descripti on_price _origin_roast _flavor _aroma_acidity_body).You can assume that the fieldsPro
20、duct.The fields are separated by an underscore ( themselves do not contain any underscores.Class CoffeeBrewerClass CoffeeBrewer models a coffee brewer. It extends classInstance variables:« model. The model of the coffee brewer* waterSupply . The water supply ( Pour-over or Automatic )« nu
21、mberOfCups The capacity of the coffee brewerConstructor and methods: public CoffeeBrewer(Stri ng in itialCode, String in itialDescripti on, double in itialPrice,«Stri ng in itialModel, Stri ng in itialWaterSupply, int ini tialNumberOfCups)Constructor that initializes the instance variablescode,
22、 description , pricemodel, waterSupply , and numberOfCups« public Stri ng getWaterSupply() . Returns the value of instance variable waterSupply .« public int getNumberOfCupsO . Returns the value of instance variable nu mberOfCups« Stri ng toStri ng() .Overrides the method toStri ng in
23、 the class Object. Returns the string representation of aCoffeeBrewer object. The String returnedhas the following format:code_description _price _model_waterSupply _numberOfCupsThe fields are separated by an underscore (_ ). You can assume that the fieldsthemselves do not contain any underscores.Cl
24、ass OrderItemClass OrderItem models an item in an order.Instance variables:« product . This instance variable represents the one-way association between OrderItem and Product . It contains a reference to aProduct object.« qua ntity . The quantity of the product in the order.Constructor and
25、 methods:« public Orderltem(Product in itialProduct, int in itialQua ntity)Constructor that initializes the instance variablesproduct and quantity* public Product getProduct() . Returns the value of the instance variable product , a reference to a Product object.* public int getQua ntity(). Ret
26、urns the value of the instance variablequantity .* public void setQua ntity(i nt n ewQua ntity). Sets the instance variablequantity to the value of parameternewQuantity.* public double getValue() . Returns the product of qua ntity and price .« Stri ng toStri ng() .Overrides the method toStri ng
27、 in the class Object. Returns the string representation of anOrderitem object. The Stringrepresentation has the following format:qua ntityproduct-code product-priceThe fields are separated by a space. You can assume that the fields themselves do not contain any spaces.Test driver classesComplete imp
28、lementations of the following test drivers are provided in the student archive.Use these test drivers to verify that your code works correctly.* ClassTestProduct«ClassTestCoffee«ClassTestCoffeeBrewer* ClassTestOrderitemFilesThe following files are needed to complete this assignment:«
29、stude nt-files.zip Download this file. This archive contains the following:o TestProduct.javao TestCoffee.javao TestCoffeeBrewer.javao TestOrderitem.javaTasksimplement classes Product , Coffee , CoffeeBrewer , and Orderitem . Document usingJavadoc and follow Sun's code conventions. The following
30、 steps will guide you through this assignment. Work incrementally and test each increment. Save often.1. Extract the files by issuing the following command at the command prompt:C:> un zip stude nt-files.zip2. Then , implement class Product from scratch. Use TestProduct driver to test your implem
31、entation.3. Next , implement class Coffee from scratch. Use TestCoffee driver to test your implementation.TestCoffeeBrewerTestOrderItem driver to4. Then , implement classCoffeeBrewer from scratch. Usedriver to test your implementation.5. Finally , implement class OrderItem from scratch. Use test you
32、r implementation.SubmissionUpon completion, submit only the following:1. Product.java2. Coffee.java3. CoffeeBrewer.java4. OrderItem.javaExperiment 2 Implementing the Collections in theGourmet Coffee System (4 Hours)Prerequisites, Goals, and OutcomesPrerequisites:Before you begin this exercise, you n
33、eed mastery of the following:« Collectionso Use of class ArrayListo 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 collectionsBackgro undIn this assignment, you w
34、ill implement the classes in theGourmet Coffee System that usecollections.Descriptio nThe following class diagram of the collections:Gourmet Coffee Systemhighlights the classes that useCatalog+add Piroductprod jet: Pnoduot+get Produdtfade: String): Product+itera!onQ : l &rat&r< Pno duct &
35、gt;+get MjmberOff'radLicteO: snt=praducts QJProduct-code :滋ring-descnption : String-price : double+getCodaQ : String +g«tDescfiptiQnO: String 4getPiriceO : double!«quals(object:Object) : b&olean -rtoSttingO : SBring-productJ1Orderltem-qiuantity: irrtetPnoductO: Product hget QMnftW)
36、 : irrt -ietQuaritirytheiu Quantity int) +getXilueQ: double: rtcSlringO : StungO.x / -itemsCoffee-origin : String-mast: Siring-ia 詢: $Ding -aroma : String -acidity: Strinfl body: String+get OriginO: SiringCo Brewermodi 皂I: String-UBterSupply: String -numberOCups : int +getMbdelO : String -hgetWrter
37、Supply ; String +get NumberOICupsO : Spring Ho SlringO : String也臥 ft&astQ. Sting +get FlavorQ : String 料骯妣rnaO : Soing +gstA>dit)0 : Suing 也et Bod旳:String-rto StriingQ : StringFigure 2 Gourmet Coffee System class diagramComplete implementations of the following classes are provided in the stu
38、dent archive:* Coffee* CoffeeBrewer* Product* OrderItem* GourmetCoffeeIn this assignment, you will implement the following classes: Catalog Order Sales GourmetCoffeeThe class specifications are as follows:Class CatalogThe class Catalog models a product catalog. This class implements the interface It
39、erable<Product> to being able to iterate through the products using thefor-eachloop.Instance variables:« products An ArrayList collection that contains references to instances of class Product.Constructor and public methods:« public Catalog。 一 Creates the collection products , which
40、is initially empty.« public void addProduct(Product product) Adds the specified product to the collection products .* public lterator<Product> iterator() Returns an iterator over theinstances in the collection products .* public Product getProduct(Stri ng code) Returns a reference to theP
41、roduct instance with the specified code. Returnsnull if there are no products inthe catalog with the specified code.* public int getNumberOfProductsO Returns the number of instances in the collection products .Class OrderThe class Order maintains a list of order items. This class implements the inte
42、rface Iterable<OrderItem> to being able to iterate through the items using thefor-eachloop.Instance variables:* items An ArrayList collection that contains references to instances of class OrderItem .Constructor and public methods:* public Order()Creates the collectionitems , which is initiall
43、y empty.*public void addltem(Orderltem orderItem) Adds the specified order item to the collectionitems .public void removeltem(Orderltem orderItem) Removes the specifiedorder item from the collectionitems .public Iterator<OrderItem> iterator() Returns an iterator over theinstances in the colle
44、ctionitems .public OrderItem getltem(Product product) Returns a reference to the OrderItem instance with the specified product. Returnsnull if there are no itemsin the order with the specified product.public int getNumberOfltemsO Returns the number of instances in thecollection items .public double
45、getTotalCost() Returns the total cost of the order.ClassSalesThe class Sales maintains a list of the orders that have been completed. This class implements the interface Iterable<Order> to being able to iterate through the orders using the for-each loop.Instance variables:orders An ArrayList c
46、ollection that contains references to instances of class Order.Constructor and public methods:public Sales() Creates the collectionorders , which is initially empty.public void addOrder(Order order) Adds the specified order to thecollection orders .public Iterator<Order> iterator() Returns an
47、iterator over the instancesin the collectionorders .public int getNumberOfOrders() Returns the number of instances in thecollection orders .ClassGourmetCoffeeThe class GourmetCoffee creates a console interface to process store orders. Currently, it includes the complete implementation of some of the
48、 methods. The methodsare incomplete anddisplayNumberOfOrders and displayTotalQuantityOfProductsshould be implemented. The following is a screen shot of the interface:01 Quit(1J Display catalog2J Display pi'Oduct3 Display current order41 Add Enodifi/ product to : in current order(S Aemove product
49、; from current order6J Register oale of current orderE7J Display sales8 J Display number of orders with a specif ic product 9 J Displai/ the total quantity sold f or each product choice>Figure 3 Executi on of GourmetCoffeeInstance variables:« catalog A Catalog object with the products that c
50、an be sold.* curre ntOrder An Order object with the information about the current order.* sales A Sales object with information about all the orders sold by the store.Constructor and public methods:* public GourmetCoffeeSolutio n() Initializes the attributes catalogcurrentOrder and sales . This cons
51、tructor is complete and should not be modified.* public void displayCatalog Displays the catalog. This method is complete and should not be modified.* public void displayProductlnfo() Prompts the user for a product code and displays information about the specified product. This method is complete an
52、d shouldnot be modified.* public void displayOrder() Displays the products in the current order. This method is complete and should not be modified.* public void addModifyProduct() Prompts the user for a product code and quantity. If the specified product is not already part of the order, it is adde
53、d;otherwise, the quantity of the product is updated. This method is complete and should not be modified.* public void removeProduct() Prompts the user for a product code and removes the specified product from the current order. This method is complete and should not be modified.* public void saleOrd
54、er() Registers the sale of the current order. This method is complete and should not be modified.« public void displayOrdersSold() Displays the orders that have been sold.This method is complete and should not be modified.« public void displayNumberOfOrders(Product product) Displays thenum
55、ber of orders that contain the specified product. This method is incomplete and should be implemented.« public void displayTotalQua ntityOfProducts() Displays the totalquantity sold for each product in the catalog. This method is incomplete and should be implemented.Test driver classesComplete
56、implementations of the following test drivers are provided in the student archive:«ClassTestCatalog«ClassTestOrder*ClassTestSalesFilesThe following files are needed to complete this assignment:«stude nt-files.zip 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 imple
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 【正版授權】 ISO/TR 33402:2025 EN Good practice in reference material preparation
- 2024年租賃合同:房產(chǎn)、車輛、設備等租賃細節(jié)及合同標的
- 智能臺燈課程設計 總結(jié)
- 搖擺式送料機構課程設計
- 專題06 三角形(全等、相似)(2大易錯點分析+19個易錯點+易錯題通關)-2024年中考數(shù)學考試易錯題(解析版)
- 端口掃描器課程設計
- 自然心教育愛課程設計
- 花卉拼貼課程設計
- 竹片銑槽機課程設計
- 液壓設計課程設計總結(jié)
- 放射性粒子植入自我評估報告
- 2023年山西云時代技術有限公司招聘筆試題庫及答案解析
- 浙大中控DCS系統(tǒng)介紹(簡潔版)
- GB/T 16288-2008塑料制品的標志
- GB/T 14486-2008塑料模塑件尺寸公差
- 北京市海淀區(qū)2022-2023學年高三期末考試歷史試題及答案
- 頂板管理實施細則
- 2022年杭州西湖文化旅游投資集團有限公司招聘筆試試題及答案解析
- 中國青年運動史PPT模板
- DB32T 4132-2021 城鄉(xiāng)污泥(淤泥)燒結(jié)節(jié)能磚自保溫墻體系統(tǒng)應用規(guī)程
- (完整word)SFC14 or SFC15 的使用詳細講解
評論
0/150
提交評論