我如何在类图中表示这种关系? [英] How I can represent this relation in class diagram?

查看:97
本文介绍了我如何在类图中表示这种关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个Java应用程序,其中每个类都进行处理,最后它创建另一个类的实例。它还会调用此类的方法,并将结果传递给该方法的参数,如下所示:

I made a Java application where each class performs a processing and at the end it creates an instance of another class. It also calls a method of this class and passes results to it in the parameters of the method like this:

public class Matrix{
     public double CalculerMinimum()
     {
        ....
           if ((result < min)) {
                        min = result;
               }
       

            Liste lis  = new Liste();
            lis.getFile(min);
         return min;
     }
 }


public class Liste{
     public string getFile(double min)
     {
        ....
           
         return lien;
     }
}

类之间的关系是什么?我如何用类图来表示呢?

What is the relationship between classes? how I can represent that with a class diagram?

推荐答案

您的矩阵类创建并使用 Liste 类。这称为依赖性。您可以用带有虚线箭头和«use»和/或«create»的类图来表示它。

Your Matrix class creates and uses the Liste class. This is called a dependency. You can represent it in a class-diagram with a dotted arrow and «use» and/or «create».

您的代码未显示任何协会概括。在操作的实现中使用 Liste 的事实不足以建立关联:此 Liste 是本地的,并封装在操作中;这两个类之间没有概念上的关联(并且您可以想象 CalculerMinimum()的实现不使用任何 Liste )。

Your code shows no kind of association nor generalization. The fact that a Liste is used in the implementation of an operation is not sufficient to make an association: this Liste is local and encapsulated in the operation; there is no conceptual association between the two classes themselves (and you could imagine an implementation of CalculerMinimum() that doesn't use any Liste).

您无法在类图中表示行为的动态。如果您对动态性感兴趣,则需要使用行为图

What you cannot represent in the class-diagram is the dynamic of the behavior. If you're interested in the dynamics you'd need to use a behavior diagram.

这篇关于我如何在类图中表示这种关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆