资源描述:
《面相对象(object-oriented)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、面相对象(Object-oriented)First,thedesignideaStartingfromtheobjectiveexistenceintherealworld,thesoftwaresystemisconstructed,andthenaturalthinkingmodeofthehumanbeingisusedasmuchaspossibleinthesystemconstructionAbstract,classification,inheritance,aggregationandpolymorphismofthought,methodan
2、dprincipleObjects:attribute,methods,staticattributes,anddynamicpropertiesAnabstractconceptusedbyaclasstodescribethesamekindofshapeAclassisatemplateobjectforanobjectandaninstanceofaclassAssociationInheritancerelationsolidlineAggregationrelation;assembledhollowcompositesolidImplementin
3、grelationaldashedlinespolymorphic1,whichclassesandwhatobjects?2、propertiesandmethodsownedbyeachcategoryandobject3,therelationshipbetweenclassesandclassesEverythinghasitsobjectFirst,classesaredefinedonlybyobjects,members,variables=attributes,methods=functionsObjectsarepackagesthatcanb
4、econsideredstaticattributes(membervariables)anddynamicproperties(Methods)Aclassisatemplateusedtocreateobjectsofthesametype.Inaclass,themembervariablesandmethodsthataresupposedtobedefinedbytheobjectaredefinedPublicclassDog{StringfurColor;Floatheight;Floatweight;VoidcatchMouse(Mouse,m)
5、{M.scream();}Public,static,void,main(String[],args){Dog,dg=new,Dog();Mouse,m=new,Mouse();Dg.catchMouse(m);}}ReuseableExtensibilitymaintenanceandreplacementismoreconvenientObjectshaveinterfacestoexternalservices:theycanbereusedbyinheritanceObjecthidestheimplementationofinternalservice
6、s:canbereusedbyaggregationTwo,classdefinition:ClassPerson{//membervariablesPrivateintid;Privateintage=20;//definitionmethodPublic,int,getAage(){Returnage;}Public,viod,setAge(int,I){Age=i;}Public,int,getId(){Returnid;}}DeclareassignuseMembervariable:anydatatype,includingthebasetypeand
7、referencetype,canbeinitializedbydefaultScopeofactionwholeclassLocalvariablesmustbeinitializedQuote:TwoblockstorageAclassisastaticconceptTheobjectisnew,andeachmembervariableintheclassoftheheapclasshasdifferentvaluesindifferentobjects,andthemethodonlytakesmemorywhenoneexecutesHeapclass
8、storageisthe