文档介绍:该【Chapter 1 Introduction to Object-oriented programming and software Development课件 】是由【yzhluyin9】上传分享,文档一共【22】页,该文档可以免费在线阅读,需要了解更多关于【Chapter 1 Introduction to Object-oriented programming and software Development课件 】的内容,可以使用淘豆网的站内搜索功能,选择自己适合的文档,以下文字是截取该文章内的部分文字,如需要获得完整电子版,请下载此文档到您的设备,方便您编辑和打印。Chapter1
IntroductiontoObject-orientedProgramming
and
SoftwareDevelopment
©2000McGraw-Hill
Chapter1-1
IntroductiontoObject-OrientedProgrammingwithJava--Wu
Chapter1Objectives
Afteryouhavereadandstudiedthischapter,youshouldbeableto
Namethebasiccomponentsofobject-orientedprogramming.
Differentiateclassesandobjects.
Differentiateclassandinstancemethods.
Differentiateclassandinstancedatavalues.
Drawobjectdiagramsusingiconsforclasses,objects,andothercomponentsofobject-orientedprogramming.
Describethesignificanceofinheritanceinobject-orientedprograms.
Nameandexplainthestagesofthesoftwarelifecycle.
©2000McGraw-Hill
2
IntroductiontoObject-OrientedProgrammingwithJava--Wu
ClassesandObjects
Object-orientedprogramsuseobjects.
Anobjectisathing,,Vehicle,Employee,etc.
Tocreateanobjectinsidethecomputerprogram,wemustprovideadefinitionforobjects—howtheybehaveandwhatkindsofinformationtheymaintain—calledaclass.
Anobjectiscalledaninstanceofaclass.
©2000McGraw-Hill
3
IntroductiontoObject-OrientedProgrammingwithJava--Wu
GraphicalRepresentationofaClass
Account
Theclassnameappearsontopoftheicon.
Aniconforaclassistherectangle.
©2000McGraw-Hill
5
IntroductiontoObject-OrientedProgrammingwithJava--Wu
Instance-ofRelationship
Employee
Employee
Bill
Employee
Steve
Employee
Andy
Theclassnamecanbeomittedsinceitisclearwhichclasstheseobjectsbelongto.
Thedottedlineshowstheinstance-ofrelationship.
Beforeyoucancreateinstancesofaclass,theclassmustbedefined.
©2000McGraw-Hill
6
IntroductiontoObject-OrientedProgrammingwithJava--Wu
MessagesandMethods
Toinstructaclassoranobjecttoperformatask,wesendamessagetoit.
Youcansendamessageonlytotheclassesandobjectsthatunderstandthemessageyousenttothem.
Aclassoranobjectmustpossessamatchingmethodtobeabletohandlethereceivedmessage.
Amethoddefinedforaclassiscalledaclassmethod,andamethoddefinedforanobjectiscalledaninstancemethod.
Avaluewepasstoanobjectwhensendingamessageiscalledanargumentofthemessage.
©2000McGraw-Hill
7
IntroductiontoObject-OrientedProgrammingwithJava--Wu
SendingaMessageandGettinganAnswer
Thismessagehasnoargument.
Account
chk-008
getMonthlyFee
monthlyfee
Themethodreturnsthevaluemonthlyfeebacktothemessagesender.
©2000McGraw-Hill
9
IntroductiontoObject-OrientedProgrammingwithJava--Wu
CallingaClassMethod
Account
getAverageBalance
averagebalance
Theaveragebalanceofallaccountsisreturned.
©2000McGraw-Hill
10
IntroductiontoObject-OrientedProgrammingwithJava--Wu
SummaryofClassandObjectIcons
<result>
<ClassName>
Squaredcornersareusedforaclassandclassmethods.
Aninstancemethodiconisdrawninadottedline.
<ClassName>
<ObjectName>
<result>
Roundedcornersareusedforaclassandclassmethods.
©2000McGraw-Hill
11
IntroductiontoObject-OrientedProgrammingwithJava--Wu
SampleInstanceDataValue
Account
SV129
Account
SV506
Account
SV008
currentbalance
currentbalance
currentbalance
AllthreeAccountobjectspossessthesameinstancedatavaluecurrentbalance.
Theactualdollaramountsare,ofcourse,different.
©2000McGraw-Hill
13
IntroductiontoObject-OrientedProgrammingwithJava--Wu