StarUML类图的六种关系
一、 泛化(Generalization)
样式:实线+箭头
泛化关系图(men类继承person类):
代码:
1. public class Person{
2. }
3. Public class men extend person{
4. }
二、 实现(Realization)
样式:实线+圆圈
实现关系图(猪八戒类实现36变):
1. Public interface 36magic{
2. Public abstract void 36magic();
3. }
4. public class zhubajie implements 36magic{
5. public void 36magic();
6. }
三、依赖(Dependency)
样式:虚线+箭头
依赖关系图(PS:动物类依赖水类生长):
1. Public class Water(){
2. }
3. Public class Animal(){
4. Public void Growup(water){
5. }
6. }
四、 聚合(aggregation)
样式:实线+空菱形
聚合关系图(PS:汽车由轮胎组装而成,且轮胎能独立存在成为一个个体)
1. Public class car{
2. Public Tyre tyre;
3. Public car(Tyre tyre){
4. this.tyre=tyre;
5. }
6. }
五、 组合(Composition)
样式:实线+实菱形
组合关系图(PS:公司类由各个部门类组成,且各个部门不能离开公司独立存在):
1. Public class company{
2. Public Department department;
3. Public company(){
4. Department=new department();
5. }
6. }
六、 单向关联(Directed Association)
样式:实线+箭头
组合关系图(PS:学生被课程关联)
1. Public class student{
2. Public course courses;
3. Public student(){
}
4. }
5. Public class course{
6. Public course(){
}
7. }
来源:oschina
链接:https://my.oschina.net/u/4393724/blog/4658203