第12章(2)

2019-03-09 23:13

290 U ML与软件建模

12.4.5 可选对可选关联的映射

A0..1a0..1bB

图12-7 A和B之间的可选对可选关联

(a) (b) (c)

图12-8 可选对可选关联关系的更新

12.4.6 可选对多关联的映射

A0..1a*bB

图12-9 可选对多关联

(a) (b) (c)

图12-10 可选对多关联关系的更新

// File: A.h #include #include %using namespace std; ...

291 第12章 UML模型的C++实现

class A { friend class B; public:

A( ); ~A( );

...

const set& getptrSet( ) const; void addB(B* b) ; void removeB(B* b); ...

private: set ptrSet; }; ...

12.4.7 强制对多关联的映射

A1a*bB

图12-11 强制对多关联

12.4.8 多对多关联的映射

A*a*bB

图12-12 多对多关联

(a) (b) (c)

图12-13 多对多关联关系的更新

12.4.9 有序关联的映射

A0..1a{ordered}*bB

292 U ML与软件建模

图12-14 有序关联

// File: A.h #include #include \

using namespace std; ...

class A { friend class B; public: A( ); ~A( ); ... const list& getptrSet( ) const; void addB(B* b) ; void removeB(B* b); ... private: list ptrSet; }; ...

12.4.10 关联类的映射

Customer0..1customer*bookBookCustomer1custBook1book

Purchase*Purchase0..1purchaseOfCustpurchaseOfBook (a) (b)

图12-15 关联类的映射

头文件Purchase.h //File: Purchase.h ...

class Purchase {

friend class Customer; friend class Book;

public: Purchase(const Customer& customer, const Book& book);

~Purchase( ); ...

// Association accessor methods

void setCustomer(Customer* newCustomer);

293 第12章 UML模型的C++实现

const Customer* getCustomer( ) const; void setBook(Book* newBook); const Book* getBook( ) const;

protected: ... private:

...

// Association attribute storage Customer* customPtr; Book* bookPtr;

}; ...

头文件Customer.h // File: Customer.h ...

class Customer { }; ...

头文件Book.h // File: Book.h ...

class Book {

friend class Purchase; ...

// Association accessor methods

void setCustomer(Purchase* newCustomer); const Purchase* getCustomer( ) const; public:

friend class Purchase; ...

//Association accessor methods

const CmapPtrToPtr& getBookSet( ) const; void addBook(Purchase* newBook); ... ...

//Association attribute storage CmapPtrToPtr bookOfPurchaseSet; public:

protected: private:

294 U ML与软件建模

protected: }; ...

... ...

// Association attribute storage Purchase* customerOfPurchasePtr; private:

12.5 受限关联关系的映射

CustomerBookID0..1customer*bookBook

图12-16 受限关联

表12-2 受限关联映射表

非限定符端的多重性 1,0..1 1,0..1{ordered} // File: Customer.h #include #include #include #include %using namespace std; ...

class Customer { public:

...

// Association accessor methods

const set& getBookSet(String BookID) const; void addBook(String BookID, Book* newBook); void removeBook(String BookID, Book* oldBook);

实现策略 Map Map 非限定符端的多重性 * *{ordered} 实现策略 Multimap Multimap ... private: }

...

// Association attribute storage

multimap bookDictSet;


第12章(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:09生毕业论文(设计)工作的暂行规定

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: