软件设计课件:Lecture 08 CPP Inheritance.pptVIP

  • 0
  • 0
  • 约3.07万字
  • 约 75页
  • 2021-11-30 发布于安徽
  • 举报
* * * * * * * * * * Class Diagram class name attributes methods composition dependency, friend function Align elements as possible No cross lines, no diagonal lines Diagram of One Class Class name in top of box Write interface on top of interfaces names Use italics for an abstract class name Attributes Should include all fields of the object Also includes derived properties Operations / Methods May omit trivial (get/set) methods But dont omit any methods from an interface! Should not include inherited methods Class Attributes Attributes (fields, instance variables) visibility name : type [count ] = defaultValue Visibility: + public # protected - private ~ package (default) / derived Underline static attributes Derived attribute: not stored, but can be computed from other attribute values Attribute example: - balance : double = 0.00 Class Operations / Methods Operations / Methods visibility name (parameters ) : returnType Underline static methods Parameter types listed as (name: type) Omit returnType on constructors and when return is void Method example: + distance(p1: Point, p2: Point): double Comments Represented as a folded note, attached to the appropriate class/method/etc by a dashed line Relationships btwn. Classes Generalization: an inheritance relationship Inheritance between classes Interface implementation Association: a usage relationship Dependency Aggregation Composition Generalization Relationships Hierarchies drawn top-down with arrows pointing upward to parent Line/Arrow styles differ based on parent: class : solid, black arrow abstract class : solid, white arrow interface : dashed, white arrow We often dont draw trivial / obvious relationships, such as drawing the class Object as a parent Associational Relationships 1. Multiplicity (how many are used) * ? 0, 1, or more 1 ? 1 exactly 2..4 ? between 2 and 4, inclusive 3..* ? 3 or more 2. Name (what relationship the objects have) 3. Navigability (direction) Multiplicity One-

文档评论(0)

1亿VIP精品文档

相关文档