UML Class Diagrams

文章推薦指數: 80 %
投票人數:10人

Class (i.e. static) methods and fields are indicated by underlining; Constant (i.e. final) fields are indicated via naming convention: constants should be in ... UMLClassDiagrams ClassName visattribute:type visoperation(arglist):returntype where vis=visibility(+forpublic,-forprivate) attribute=datamember(akafield) operation=method(orconstructor) Note: Thearglistisalistofparametertypes(e.g.,int,double,String); parameternamesarenotincludedintheUMLclassdiagram Methodsthatdon'treturnavalue(i.e.voidmethods)shouldgiveareturntypeofvoid Class(i.e.static)methodsandfieldsareindicatedbyunderlining Constant(i.e.final)fieldsareindicatedvianamingconvention:constantsshouldbeinALL_CAPS   Example: UMLdiagram Employee -name:String -payRate:double -EMPLOYEE_ID:int -nextID:int +STARTING_PAY_RATE:double +Employee(String) +Employee(String,double) +getName():String +getEmployeeID():int +getPayRate():double +changeName(String):void +changePayRate(double):void +getNextID():int CorrespondingJavaClass publicclassEmployee{ privateStringname; privatedoublepayRate; privatefinalintEMPLOYEE_ID; privatestaticintnextID=1000; publicstaticfinaldoubleSTARTING_PAY_RATE=7.75; publicEmployee(Stringname){ this.name=name; EMPLOYEE_ID=getNextID(); payRate=STARTING_PAY_RATE; } publicEmployee(Stringname,doublestartingPay){ this.name=name; EMPLOYEE_ID=getNextID(); payRate=startingPay; } publicStringgetName(){returnname;} publicintgetEmployeeID(){returnEMPLOYEE_ID;} publicdoublegetPayRate(){returnpayRate;} publicvoidchangeName(StringnewName){name=newName;} publicvoidchangePayRate(doublenewRate){payRate=newRate;} publicstaticintgetNextID(){ intid=nextID; nextID++; returnid; } }



請為這篇文章評分?