其他分享
首页 > 其他分享> > UML图示详解

UML图示详解

作者:互联网

UML图示详解

前言

绘制你的第一个UML类图

 public class Person {
     private Integer id;
     private String name;
 ​
     public String getName() {
         return name;
     }
 ​
     public void setName(String name) {
         this.name = name;
     }
 }

image-20220505184816035.png

image-20220505185311911.png

类之间关联关系

image-20220505192922336.png

依赖&关联

依赖

 public class DependencyAndRelation {
     private Dependency dependency;
 ​
     public void createRelation(Relation relation) {
 ​
     }
     public Study startStudy() {
         return null;
     }
     public void fav(){
         Eat eat = new Eat();
     }
 }
 class Dependency{}
 class Relation{}
 class Study{}
 class Eat{}

image-20220506082410599.png

image-20220506191619560.png

关联

image-20220506192636923.png

image-20220506193259851.png

泛化&实现

 public class ExtendAndImplent {
 }
 abstract class Happy{
     abstract void sayHi();
 }
 ​
 class TodayHappy extends Happy {
 ​
     @Override
     void sayHi() {
         System.out.println("我今天很开心");
     }
 }
 ​
 interface Operator{
     public void opt();
 }
 ​
 class AddOperator implements Operator {
 ​
     @Override
     public void opt() {
         System.out.println("我会加法");
     }
 }

image-20220506195336362.png

聚合&组合

image-20220507084435379.png

聚合

 public class AggregationAndComposition {
     public static void main(String[] args) {
         Cat cat = new Cat();
     }
 }
 class Cat{
     private Appendage appendage;
 }
 class Appendage{
 ​
 }

image-20220507084806942.png

组合

 public class AggregationAndComposition {
     public static void main(String[] args) {
         Cat cat = new Cat();
     }
 }
 class Cat{
     private Appendage appendage = new Appendage();
 }
 class Appendage{
 ​
 }

image-20220507085937563.png

小结

标签:图示,依赖,聚合,public,详解,UML,关联,class
来源: https://www.cnblogs.com/Leo_wl/p/16657785.html