2023年面向对象程序设计实验指导书.pdf
《2023年面向对象程序设计实验指导书.pdf》由会员分享,可在线阅读,更多相关《2023年面向对象程序设计实验指导书.pdf(76页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、面 向 对 象 程 序 设 计实 验 指 导 书黄 利 萍 刘 国 奇东北大学软件学院2023.9*目 录面向对象程序设计。错误!未定义书签。实验指导书错误!未定义书签。前 言错误!未定义书签。实验规定。错误!未定义书签。E x periment 1 I mpleme n t ing t h e C o 1 1 ect i o n s i n t he G ourmet Co f fee System(4 Hours)错误!未定义书签。B ackground。错误!未定义书签。D e sc r ipti o n。错误!未定义书签。Files.错误!未定义书签。T a s k s。错误!未定义书
2、签。Experim e n t 2 Usin g Des i g n Patterns i n the Gourmet C o f f ee Sys t e m(4Hou r s)。错误!未定义书签。Backg round。错误!未定义书签。D e scription.错误!未定义书签。F il e s.错误!未定义书签。Task s。错误!未定义书签。Ex p erime n t 3 U s i n g File I/O i n t he G ourme t C offee S y stem(4 Hours)。错误!未定义书签。B a ckgro u nd。错误!未定义书签。Descript
3、ion.错误!未定义书签。F ile s.错误!未定义书签。Tasks.错误!未定义书签。Ex p e rimen t 4 Im p lemeriting a GUI f o r the Gourm e t C o f fee S ystem(4 H ours).错误!未定义书签。B a c k g ro u n d。错误!未定义书签。Des cripti o n.错误!未定义书签。F i les错误!未定义书签。Tasks。错误!未定义书签。前营面向对象的思想可以渗透到需求分析、系统建模、体系结构设计、程序设计与实现、系统测试等多个方面,它是描述现实世界复杂对象的相称直接并且直观的有效手段,
4、对于提高系统质量、开发效率和代码重用率,都有明显的效果。面向对象程序设计课程是软件工程专业的重要专业基础课程之一,该门课程注重实践性和实用性,重要通过面向对象程序设计思想和Java语言结合起来,让学生掌握面向对象程序设计思想,以及纯熟使用Java语言进行面向对象的编程,因此学生不能满足于只听懂老师讲授的课堂内容,看懂书上的程序,应将课堂教学与实践环节紧密结合,使得学生加深对讲授内容的理解,学会上机调试程序。也就是善于发现程序中的错误,并且能不久地排除这些错误,使程序能对的运营。面向对象程序设计 是结合卡耐基梅隆大学的SS D 3而形成的课程,该课程的教学体系和实验体系都很完整,并且东北大学软件
5、学院也提供了良好的教学实验环境,希望同学们可以充足运用实验条件,认真完毕实验,从实验中得到应有的锻炼和培养。希望同学们在使用本实验指导书及进行实验的过程中,可以帮助我们不断地发现问题,并提出建议,使 面向对象程序设计真正可以帮助同学们学习。实验规定 面向对象程序设计课程实验的目的是为了使学生在课堂学习的同时,通过一系列的实验,使学生加深了解和更好地掌握 面向对象程序设计课程教学大纲规定的内容。在 面向对象程序设计的课程实验过程中,规定学生做到:(1)预习实验指导书有关部分,认真做好实验内容的准备,就实验也许出现的情况提前作出思考和分析。(2)仔细观测调试程序过程中出现的各种问题,记录重要问题,
6、作出必要说明和分析。(3)遵守机房纪律,服从辅导教师指挥,爱惜实验设备。(4)实验课程不迟到,如有事不能出席,所缺实验一般不补。(5)本实验采用的开发环境为E clipse,同学在做实验之前规定熟悉该集成开发环境。4E x p e rime n t 1 Impleme n t i n g the G ou rmetCoff e e System(4 Hours)P rerequisites,Goals,and 0 u tc o mesP rer eq uisites:B e fo re you be g i n this exerc i s e z you need mastery of t
7、h e followin g:0 bjec t Oriented P ro gramm i ngo Knowledge of clas s designC 1 ass a tt r i bute sConstructo rs Acc e s s or met h ods Muta t o r metho d so Know 1 edg e of i n h er i tan c e How to i m p 1 ement a sp e cializa t i on/gene r al i z ation re I at i ons h ip u s i n g inh e r i t anc
8、eGoals:Re i nfo r c e y our abi 1 ity to implem e n t Java c lasses us i ng inhe r itance.Out com e s:You will dem o ns t rate ma s t e ry of th e fol 1 owing:Impl e ment i ng the const r uctors,a c c e s s ors,an d mu t a to r s of aJa v a c la s s Using in h e ritan c e to im p 1 ement a spec i al
9、iz a t i on/g e nera 1 iza t i onre I a tlonshipBackgroun dThis ass i g nme n t ask s yo u t o i mplement some of the c 1 as s es i n theGourmet Cof f ee S y s tern s p ecified o n Ex e rcise 2.D e s c r i p t i o nI n t hi s a s s e s s ment,you will i mp 1 ement t he cla s s e s and r e 1 at i o n
10、 s h i psi I 1 u s tra t ed i n th e fo 1 1 owing class di a g ram:Product-code:String-description:String-price:doubleet CodeQ:String+get Description。:String为etPrioe。:doubley qual式object:Object):booleanrtoStringO:StringOrderitem-quantity:int-product1为etPnoduaO:Product4etQuarrtjtO:int+setQuantity(new
11、 Quant it/irrt)均 etSlue。:doubleMo String。:StringCoffeeorigin:String-roast:Siring-la w :String-aroma:String-acidity:String-body:String均et Origin。:String均etRoaslQ:String-etFlavorO:String与etM rraO :String与e tN d itO :String却etBodg:StringrtoStringO:String5G)1fee Brewer-model:StringuiaterSupply:Stringnum
12、ber。忙ups:int翅et岫加I。:String-tetWrterSupplO:Siring4et NjmberOfCupsO:int-rtoStringO:StringF i gu r e 1 P o rti o no f Gou r m e t C of f e e System c 1 ass diagra mThe c 1 a ss s p ecif i cations a re as f ol 1 ows:Clas s P r o du c tTh e class P rod u c t mode 1 s a generic p r od u ct in t he sto r e
13、.Instanc e va r fables:code.The uniq u e code that i de n ti f ies t he p ro d u c t d e s c rip t i o n.A s hort descr i p t io n o f the p roductp r ice.Th e p rice of t he productConst rue tor and methods:p u b lic P r o duct(S trin g i n i tia lC o d e,S trin g i n itia lD e s c rip tio n,doub 1
14、 e 1 n i t i a IP ric e)Construct r that in i tiali z es t h e inst a nee var i ables c o d e,de S cr ip t i o nz and p r i c e.p u b l i c S tr i ng g et C o de().R e tu r ns the v a lue of in s tanc e vari a bIe code.p u b 1 i c S t r i n g g e tD e s c rip ti o n().R eturns the value of in stance
15、 v ar i able de s cr i p tion.p u b l i c double g et P rice (),R e turns the value of i nstance va r iablep r ic e.b oo 1 e a n equ a 1 s(Ob j ect o b j e c t).Overrid es th e m e t hode qua Is in t he class 0 b j e c t.Two Prod u c t o bjects a re equa 1 if th ei r codes are equal.S t r i n g to S
16、 trin g O.Overrides th e me t hod t o S trin g in t he c lass 0b je c t.R e turns t h e st r i ng r e presen t a t i on of a P r odu c t object.The S t r i n g returned has the followi ng format:co d e_ de s c r i p tio n_ p r i c eTh e fields a re separated by an unde r scor e(_).Y o u c a n a ssum
17、 e that th e f i el d s thems e I v e s d o not c ont a i n a n y u n d ersco r es.Class C o f f e eThe c I a ss C o ffe e mod e Is a cof f e e product.I t ext e nds class P r od u c t.In sta nc e vari able s:o rig in.The or i g in of t h e coffee r o a s t.The roast of the coffee f l a v o r.The f
18、1 a v or of t h e coffee aroma.The aroma of the c o ffee a c id it y.The aci d ity of t h e cof fee b ody.The body o f the c offeeCon s t r uctor a nd methods:p u b li c Co f fee(S t r i n g i n i t i a 1 C o d e,St r i n g i n i t ia l De s c rip tio n,d o u b le in it ia 1 P ri c e,S trin g i n i
19、t i a l O rig in,S t r i n g in itia lR o a s t,S t r i ng in i tia lF la v o r,S trin g in i tia lA r o ma,S tri n g i n i t ialA c i d i ty,St r in g i n i t i a 1 Body)Con stru c tor th at i n i tiali z e s t h e ins t a nee v a riab 1 es code,d escrip tion,price,or i gin,r o a s t,f lavo r,aroma
20、,a c i d i t y,a nd bo d y.p u b lic S trin g ge t O rig in ().Re tu r ns the va lu e o f instan c e v a r iable o r ig in.pu b lie S trin g g e t R o as t().Return s the v a lu e o f instancevariab 1 e roast.pub l i e S tr i ng g e tF 1 avo r ().Retu r ns the value o f j n stance v ar i abl e f l a
21、 vor.p u b l i c S t rin g g etA r om a Re t u r ns the value of in s tan c e variab1 e arom a.p u b lic S tr i n g g e t A c id it y O.R e t u rns th e va 1 ue of in s t anee v ariable ac i d it y.p u b lic S trin g g etBody().Retu rns the value of ins t ance variab 1 ebody.S t r in g toS t r i n g
22、().Ov e r r i des t h e metho d toS t r ing i nthe c lass Ob j e c t.R e t urns the strin g re pre s en t ation of a C o ffe e o bject.Th e St r i ng ret u r n e d has th e fo 1 1 ow i n g f o r m a t:code_ d e s c r i p tio n p ric e o r ig i n _ roas t _ f la v o r_a r oma_aci d i t y_bodyThe fiel
23、ds are s epara t e d by a n u n derscore(_ ).You c a n a ssumethat the fiel d s thems e lv e s d o not c ontai n any un d ers c o re s.Cla s s Coffee B r ewerClass C o f f eeBrew e r models a coffee b re wer.It e xte n d s c la s s P roduct.Ins tanc e v a ri able s:mo d el.The m o de 1 of t he coff
24、e e b r ewer wat e rSupp ly.The watersupp y(Po ur-o vero r Au t omati c)numberOfCups.The ca p aci t y of the co f fee brewerConst r u ctor a nd methods:publi c Coff e eBrewe r(S tr i n g in i ti a 1 C o de,S tring in i t i a ID e scrip t i on,doub 1 e i n itia lP r ice,St r ing in i tialM odel,S t r
25、ing ini t ial Wat e rSupp 1 y,i n t in iti a 1 NumberOfCups)Con s tructor th at initi a li z es t he i n st a n c e v ari a bles c o de,d e s c ript io n z p r ice,model,water S u p p l y,and numberOfCup s.p u b lie St r ing g e tM R eturns t h e va 1 u e o f instanc e var i ab 1 e m o de 1 .public
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2023 面向 对象 程序设计 实验 指导书
限制150内