简体   繁体   English

Java类的类图的实现

[英]Implementation of class diagrams of java classes

I wanted to know how i can design a uml class diagram or uml diagrams in General of These Java classes: 我想知道如何在这些Java类的常规中设计uml类图或uml图:

public class A{
 private A parent;
 private B[] b = new B[3];
 protected int i;
 private Vector<C> c; //container for objects of class C
 }

 public class B {

 }

 public class C {
 private A owner;
 public A getOwner() {return owner;}
 }

Maybe someone who has the Software can post an example how an class diagram in uml can look lie with These Java classes. 也许拥有该软件的人可以发布一个示例,这些Java类如何显示uml中的类图。

Something like this? 像这样吗
在此处输入图片说明
EDIT0: and a simple object diagram sample EDIT0:和一个简单的对象图示例
在此处输入图片说明

Edit1: EDIT1:
explanation: in object diagram you should specify the value of each variable, here the i=1990 is an example, it could be any number. 说明:在对象图中,您应该指定每个变量的值,这里的i=1990是一个示例,可以是任何数字。

A a=new new A();
a.setI(1990);

as you see, there are two instances of class A named a and a1 . 如您所见,类A有两个实例,分别为aa1

A a=new A();
A a1=new A();

The a1 reference has no value for variable c, so it's null . a1引用没有变量c的值,因此为null

class B doesn't have anything(attribute) here. B类在这里没有任何内容(属性)。
in class A , the b variable is a array of class B , so a variable has two B references( b0 , b1 ) and a null value. 在类A ,b变量是B类的数组,因此a变量具有两个B引用( b0b1 )和一个null值。

B b0=new B();
B b1=new B();
a.setB(new B[]{b0,b1,null});
////
B b2=new B();
a1.setB(new B[]{null,null,b2});

and about the :C and :Vector<C> , why doesn't it have a name lie a1 or b0 ? 关于:C:Vector<C> ,为什么它的名字不是a1b0 because there is no need for pointer(reference) for the class, so it doesn't need a pointer, in other word an object from Vector<> and two objects from C are created and passed to the host class A . 因为该类不需要指针(引用),所以它不需要指针,换句话说,创建了Vector<>对象和C两个对象,并将它们传递给宿主类A

a.setC(new Vector<C>());
a.getC().put(new C(a));
a.getC().put(new C(a));

and about the owner in C class, assume that the owner is set during the object creation by constructor, or has set by a indirect reference (using Ac ). 和关于ownerC类,假定所有者被构造对象创建过程中设置,或者已经设定通过(使用间接引用Ac )。

I hope I could give some hand dude. 我希望我能帮上忙。 Software: UMLet 软体:UMLet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM