中国高校课件下载中心 》 教学资源 》 大学文库

四川大学:《Java面向对象编程》课程PPT教学课件(Object-Oriented Programming - Java)Unit 1.2 Designing Classes

文档信息
资源类别:文库
文档格式:PPT
文档页数:47
文件大小:782.5KB
团购合买:点击进入团购
内容简介
– 1.2.1 UML Class Diagrams – 1.2.2 Relationships Between Classes – 1.2.3 Common Class Structures – 1.2.4 UML with Eclipse
刷新页面文档预览

Topics Covered Today Unit 1. 2 Designing Classes 1. 2. 1 UML Class diagrams 1.2.2 Relationships between Classes 1.2.3 Common Class structures 1.2.4 UML with eclipse

2 Topics Covered Today • Unit 1.2 Designing Classes – 1.2.1 UML Class Diagrams – 1.2.2 Relationships Between Classes – 1.2.3 Common Class Structures – 1.2.4 UML with Eclipse

UML Introduction Programming is like building a house. An architect creates a design, and a builder uses appropriate tools to carry out the design The builder does not proceed without a blueprint from the architect Software developers also need a blueprint to create complex systems The UML is a toolbox of graphical notations used to produce the blueprint a graphical l depiction of the software design UML, Unified modeling language

3 UML Introduction • Programming is like building a house. An architect creates a design, and a builder uses appropriate tools to carry out the design. The builder does not proceed without a blueprint from the architect. • Software developers also need a blueprint to create complex systems. • The UML is a toolbox of graphical notations used to produce the blueprint -- a graphical depiction of the software design • UML, Unified Modeling Language

Unified Modelling Language (UML) A graph ohio cal language for Visualising Specifying Constructin g Documenting Object-oriented software systems ·OMG( Object management Group国际对象管理 组织) is responsible for UML standard

4 Unified Modelling Language (UML) • A graphical language for – Visualising – Specifying – Constructing – Documenting • Object-oriented software systems • OMG (Object Management Group国际对象管理 组织) is responsible for UML standard

UML UML is not a method it does not outline a procedure for designing software; It is a modeling language that captures the design graphically Whatever process you use you can use uml to record the results of your anal ysis and design decisions

5 UML • UML is not a method. It does not outline a procedure for designing software; it is a modeling language that captures the design graphically. • Whatever process you use, you can use UML to record the results of your analysis and design decisions

UML The main reason to use uml notation is communication To discuss design with someone both need to understand the modeling language, not the process used to come up with the design Human language is imprecise Code is too detailed

6 UML • The main reason to use UML notation is communication. – To discuss design with someone, both need to understand the modeling language, not the process used to come up with the design. – Human language is imprecise – Code is too detailed

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

刷新页面下载完整文档
VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
相关文档