【正文】
nP r o d u c t I t e mP r o d u c t C o ll e c t io nC a r t M g rP r o d u c t M g rC a r t I n t e r f a c eM a i n P r o g r a m System Component 圖 練習(xí)步驟 生成組件包 1、 右單擊瀏覽器中的 ponent 視圖 2、 [new]—[package] 3、 命名 entities 4、 對 boundaries 和 control 包重復(fù)第 1 到第 3 步 將包加進(jìn)主 ponent 框圖 1、 雙擊 打開主 ponent 框圖 2、 將 entities、 boundary 和 control 包從瀏覽器拖動到主 ponent 框圖 繪制包依賴性 1、 從工具箱中選擇 dependency 2、 在主 ponent 框圖中單擊 boundaries 包 3、 畫出向 control 包的依賴性 4、 重復(fù) 1 到 3 步增加從 control 到 entities 包的依賴性 增加包的組件和畫出依賴性 1、 雙擊主 ponent 框圖中的 entities 包打開 entities 包的主 ponent 框圖 2、 從工具箱中選擇 package specification 3、 將包 規(guī)范放進(jìn)框圖中 4、 輸入包規(guī)范名為 CartCollection 5、 重復(fù)第 2 到第 4 步,加進(jìn) CartItem ,ProductCollection,ProductItem 包規(guī)范 6、 從工具箱中選擇 Dependency 7、 單擊 CartItem 包規(guī)范 8、 拖動到 CartCollection 包規(guī)范的依賴性線 9、 重復(fù)第 6 到第 8 步增加從 ProductItem 包規(guī)范到 ProductCollection 包規(guī)范的依賴性,并且增加從 ProductItem 包規(guī)范到 CartItem 包規(guī)范的依賴性 14 10、 用這種方法創(chuàng)建下列組件和依賴性: a) 對邊界包的 CartInterface 包規(guī)范 b) 對控制包的 CartMgr 包規(guī)范 c) 對控制包的 ProductMgr 包規(guī)范 d) 對控制包的 ProductMgr 包規(guī)范到 CartMgr 包規(guī)范的依賴性 創(chuàng)建 System Component 框圖 1、 右單擊瀏覽器中的 ponent 框圖 2、 從彈出菜單選擇 newComponent Diagram 3、 將新框圖命名為 System 4、 System ponent 框圖 將組件放進(jìn) system ponent 框圖 1、 如果需要,在瀏覽器中展開實(shí)體組件包 2、 單擊實(shí)體組件包中的 CartItem 包規(guī)范 3、 將 CartItem 包規(guī)范拖動到框圖中 4、 重復(fù)第 2 到第 3 步將 CartCollection、 ProductItem 與 ProductCollection 包規(guī)范放到框圖上 5、 用這個方法將下列組件放到框圖上 a) 邊界組件包中 CartInterface 包規(guī)范 b) 控制組件包中 CartMgr 包規(guī)范 c) 控制組件包中 ProductMgr 包規(guī)范 6、 從工具欄中選擇 Main Program 7、 將主程序放在框圖上,并取名 MainProgram 將其余依賴性加進(jìn) System Component 框圖 加進(jìn)組件后,已經(jīng)存在的依賴性自動出現(xiàn)在 System Component 框 圖中。將選項(xiàng)設(shè)置成用 UML圖注顯示可見性。 練習(xí)步驟: 設(shè)置: 1、 選擇 tools—options 2、 選擇 diagram 3、 確保選擇 show stereotypes 復(fù)選框 4、 確保選擇 how all attributes 和 show all operations 復(fù)選框 5、 確保取消 suppress attributes 和 suppress operations 復(fù)選框 創(chuàng)建 包 1、 右單擊瀏覽器中的 logical 視圖 2、 newpackage 3、 取名 entities 4、 重復(fù) 13 步,生成 boundaries 和 control 包 創(chuàng)建 main class 框圖 1、 雙擊瀏覽器中 logical 視圖內(nèi)的 main class 框圖將其打開 2、 將 entities 包從瀏覽器中拖動到框圖上 3、 將 boundaries 和 control 包從瀏覽器中拖動到框圖上 main class 框圖如下圖: EntitiesBoundariesControl 6 生成包含 Add Item to Shopping Cart 使用案例中所有類的 class 框圖 1、 右單擊瀏覽器中的 logical 視圖 2、 [new][class diagram] 3、 取名 Add Item to Shopping Cart 4、 雙擊 Add Item to Shopping Cart 框圖將 其 打開 5、 選擇類工具按鈕,并將每個類 ( CartMgr , CartInterface , ProductMgr , Product、 ProductCollection , CartCollection 與 CartItem) 加到框中 將版型加進(jìn)類中 1、 右單擊框圖中的 CartInterface 類 2、 從彈出菜單中選擇 open specification 3、 在版型字段中輸入 boundary 4、 單擊 OK 5、 右單擊框圖中的 CartMgr 來 6、 從彈出菜單中選擇 open specification 7、 在版型字段 中輸入 Control 8、 單擊 OK 9、 重復(fù) 1—4 步,指定 CartCollection、 Product、 ProductCollection 和 CartItem 類為 entity 版型 將 類組成 包 1、 在瀏覽器中, 將 CartInterface 類拖動到 boundaries 包 2、 將 CartMgr 與 ProductMgr 類拖動到 Control 包 3、 將 CartCollection、 CartCollection 類拖動 entity 包 將 class 框圖加進(jìn)每個包 1、 在瀏覽器中,有單擊 Boundaries 包 2、 選擇 newclass diagram 3、 將新框圖取名為 Main 4、 雙擊打開新框圖 5、 將 CartInterface 類從瀏 覽器拖動到框圖中 6、 關(guān)閉框圖 7、 在瀏覽器中右單擊 Entities 包 8、 選擇 newclass diagram 9、 將新框圖取名為 Main 10、 雙擊打開新框圖 11、 將 CartCollection、 Product、 ProductCollection 和 CartItem 類從瀏覽器拖動到框圖中。 五、增加角色描述 選擇瀏覽器中的客戶角色 用文檔窗口增加銷售員角色的下列描述 The customers is the individual who is purchasing items from the anization 用文檔窗口增加其余角色的描述 結(jié)果如下圖: A d d I t e m t o S h o p p in g C a r tV i e w S h o p p in g C a r tV i e w D e t a i l o f I t e m sR e m o v e I t e m f r o m S h o p p i n g C a r tB r o w s e I t e m f o r S a leP r o v i d e Fe e d b a c kC u s t o m e rC r e d i t S y s t e mP u r c h a s e I t e m s in S h o p p i n g C a r tS t o c k I n v e n t o r yR e t u r n I t e m t o S t o c kW a r e h o u s e M a n a g e rS h ip p i n g S e r v ic eS h ip O r d e rA d d N e w I t e m f o r S a leR e m o v e I t e m f o r S a l eP u r c h a s e I n v e n t o r yP u r c h a s in g M a n a g e r 3 實(shí)驗(yàn)二 對象交互( Interaction 框圖) 實(shí)驗(yàn)內(nèi)容 創(chuàng)建 Sequence 框圖和 Collaboration 框圖,在電子商務(wù)系統(tǒng)的購物推車中增加新項(xiàng)目。 1 實(shí)驗(yàn)一 使用案例與角色 創(chuàng)建訂單處理系統(tǒng)的 use case框圖 練習(xí)步驟: 一、增加系統(tǒng)用例模型包、 use case 框圖、用例和角色 1、 右單擊瀏覽器中的 use case 視圖包并選擇 NewPackage 2、 將新包命名為 System Use Case Model 3、 右單擊 System Use Case Model 包并選擇 NewUse Case Diagram 4、 將新框圖命名為 Main 5、 雙擊瀏覽器中的 Main Use Case 框圖打開框圖 6、 用用例工具欄按鈕將新用例加進(jìn)框圖中 7、 將新用例命名為 Add Item to Shopping Cart 8、 重復(fù)第 6 步到第 7 步,將其余用例加進(jìn)框圖中,包括: i. View Shopping Cart ii. View Details of Items iii. Purchase Items in Shopping Cart iv. Remove Item from Shopping Cart v. Browse Items for Sale vi. Provide Feedback vii. Srock Inventory viii. Return Item to Stock ix. Ship Order x. Add New Item for Sale xi. Remove Item for Sale xii. Purchase Inventory 9、 用角色工具欄按鈕將新角色加進(jìn)框圖中 10、 將新角色命名為 Customer 11、 重復(fù)第 9 步和第 10 步,將其余角色加進(jìn)框圖中,包括: Credit System Warehose Manager Shipping Service Purchasing Manager 三、增加關(guān)聯(lián) 用單向關(guān)聯(lián)( unidirectional association)工具按鈕在客戶角色與“ Add Item to Shopping 2 Cart”用例之間畫出關(guān)聯(lián)。 完成了 sequence 和 collaboration 框圖 實(shí)現(xiàn)步驟: 設(shè)置 選擇 [tools][options] 選擇 [diagram]標(biāo)簽 確保復(fù)選框 sequence numbering , collaboration numbering 和 focus of control 單擊 ok 退出 Options 窗口 創(chuàng)建 sequence 框圖 1、 右單擊瀏覽器中 系統(tǒng)使用案例模型的 Add Item to Shopping Cart 2、 [new][sequence diagram] 3、 取名 Main Flow 4、 雙擊打開新框圖 將角色和對象加進(jìn)框圖 1、 將 Customer 角色從瀏覽器拖動到框圖中 2、 選擇 object 工具欄按鈕 3、 單擊框圖頂部添加對象 4、 將新對象取名為 Cart Interface 5、 對下列對象重復(fù)第 3 和第 4 步: a) Cart Mgr b) Product Mgr c) Product Items d) White Crew Socks e) Cart Items 將消息加進(jìn)框圖 1、 選擇 objection message 工具欄按鈕 2、 從 Customer 角色的生命線拖動到 Cart Interface 對象生命線 3、 選中 消息時,輸入 Add white crew socks to cart 4、 重復(fù) 第 2 和第 3 步,將其他消息加進(jìn)框圖中 ? Add white crew socks to cart (在 Cart Interface 與