UML Diagrams Use case diagram(用例图) Class diagram(类图 Behavior diagrams(行为图) Statechart diagram(状态图) Activity diagram(活动图) Interaction diagrams(交互图 Sequence diagram(顺序图) Collaboration diagram(协作图) Implementation diagrams(实现图) Component diagram(组件图) Deployment diagram(部署图)
7 UML Diagrams • Use case diagram (用例图) • Class diagram (类图) • Behavior diagrams (行为图) – Statechart diagram (状态图) – Activity diagram (活动图) – Interaction diagrams (交互图) • Sequence diagram (顺序图) • Collaboration diagram (协作图) • Implementation diagrams (实现图) – Component diagram (组件图) – Deployment diagram (部署图)
Class notation a class is represented by a rectangle with three compartments The first compartment contains the name of the class the second compartment describes the attributes of the class and the third compartment describes the methods of the class
8 Class Notation • A class is represented by a rectangle with three compartments. – The first compartment contains the name of the class; – the second compartment describes the attributes of the class; – and the third compartment describes the methods of the class
UML Class Diagram NameClass name attribute: Type attribute attribute2: Type I+method1(param 1: lype, param2: Type) method +method2 (paramI: Ty pe, param2 pe pe pI rivate ·+ public protected
9 UML Class Diagram NameClass -attribute1 : Type -attribute2 : Type +method1(param1 : Type, param2 : Type) : Type +method2(param1 : Type, param2 : Type) : Type name attribute method • - private • + public • # protected
Employee class This class contains three private attributes name hourly Wage hour Worked It also contains the following public methods Methods to access the values of the attributes getName, getHourly Wage, and getHours Worked Methods to modify the values of the attributes setName set hourly Wage, and setHours Worked a method to obtain the employee's earnings getEarnings
10 Employee Class • This class contains three private attributes: – name – hourlyWage – hourWorked • It also contains the following public methods: – Methods to access the values of the attributes: • getName, getHourlyWage, and getHoursWorked – Methods to modify the values of the attributes: • setName, setHourlyWage, and setHoursWorked – A method to obtain the employee's earnings: • getEarnings
Representation of employee employee name String hourly Wage: Double -hours Worked double +getName(: String +get Hourly Wage(: Double +getHours Worked: Double +setName(newName: String +sethourly Wage(newHourly Wage: Double) +sethours Worked(new Hours Worked Double) +get Earnings(: Double
11 Representation of Employee Employee -name : String -hourlyWage : Double -hoursWorked : Double +getName() : String +getHourlyWage() : Double +getHoursWorked() : Double +setName(newName : String) +setHourlyWage(newHourlyWage : Double) +setHoursWorked(newHoursWorked : Double) +getEarnings() : Double