StarUML類圖的六種關係
1、 泛化(Generalization)
樣式:實線+箭頭
泛化關係圖(men類繼承person類):
代碼:java
1. public class Person{ 2. } 3. Public class men extend person{ 4. }
2、 實現(Realization)
樣式:實線+圓圈
實現關係圖(豬八戒類實現36變):
web
1. Public interface 36magic{ 2. Public abstract void 36magic(); 3. } 4. public class zhubajie implements 36magic{ 5. public void 36magic(); 6. }
3、依賴(Dependency)
樣式:虛線+箭頭
依賴關係圖(PS:動物類依賴水類生長):
svg
1. Public class Water(){ 2. } 3. Public class Animal(){ 4. Public void Growup(water){ 5. } 6. }
4、 聚合(aggregation)
樣式:實線+空菱形
聚合關係圖(PS:汽車由輪胎組裝而成,且輪胎能獨立存在成爲一個個體)
this
1. Public class car{ 2. Public Tyre tyre; 3. Public car(Tyre tyre){ 4. this.tyre=tyre; 5. } 6. }
5、 組合(Composition)
樣式:實線+實菱形
組合關係圖(PS:公司類由各個部門類組成,且各個部門不能離開公司獨立存在):
spa
1. Public class company{ 2. Public Department department; 3. Public company(){ 4. Department=new department(); 5. } 6. }
6、 單向關聯(Directed Association)
樣式:實線+箭頭
組合關係圖(PS:學生被課程關聯)
code
1. Public class student{ 2. Public course courses; 3. Public student(){ } 4. } 5. Public class course{ 6. Public course(){ } 7. }