你好,我正在尝试将这个UML图直接转换为java代码,下面是我的代码,它似乎无论如何都无法编译。我不太确定如何放置可选的多重性,例如 0..* 和 0..1。感谢您的帮助。
public class Person{
private String name;
private Person mom;
private Person dad;
private ArrayList<Person> child;
private ArrayList<Person> friend;
private ArrayList<School> alumni;
private School current = new School();
public Person(String name, Person mom, Person dad, ArrayList<Person> child, ArrayList<Person> friend, ArrayList<School> alumi, School current){
name = this.name;
mom = this.mom;
dad = this.dad;
child = this.child;
friend = this.friend;
alumni = this.alumni;
current = this.current;
}
}
public class School{
private String name;
private ArrayList<Person> student;
public School(String name, ArrayList<Person> student){
name = this.name;
student = this.student;
}
}
郎朗坤
繁星coding
相关分类