我可以在 UML 中识别该方法从另一个 class 调用方法吗

Can i identify in UML that method calls method from another class

我代表了这段代码:

class Enemy{
    int _health;
    void Attack(){
        Player.GetDamage(25);
    }
}

class Player{
    int _health;
    public void GetDamage(int amount){
        _health -= amount;
    }
}

在 UML 中是这样的:

表示正确吗? 我是 UML 的新手,不知道我做的事情是否正确。

不,这是不正确的。该协会是错误的。这只是一个依赖项,您需要将其显示为虚线箭头。 class 图仅显示静态结构(即 class 之间的关系)。

你在序列图中显示调用的动态部分:

Actor1 是系统中触发攻击的一些自动机。