最佳答案
显然,该图使用了扩展绘图,其中第一个隔间给出了“标准”枚举项目名称以及属性的关联值,第二个隔间是属性,第三个隔间当然是操作。 (在 BoUML 中,我更喜欢在同一个隔间中绘制项目和属性,以尊重 UML 标准)
因为它是一个枚举,所以构造函数必须是私有(private)而不是公共(public),这是图中的错误
Is it optional to enter the things below the enum part, or would that be required as well as the enum?
必须设置属性,并定义属性/操作,UserType 的可能定义是:
public enum UserType {
Student("Under Graduate Student", 1, 20),
PostStudent("PostGraduate Student", 2, 30),
AdminStaff("Administrative Staff", 3, 30),
Librarian("Librarian", 4, 40),
AcademicStaff("Academic Staff", 5, 40),
Admin("System Administrator", 6, 30);
private String name;
private int id;
private int numberOfAllowedBooksToBorrow;
private UserType(final String n, int i, int nb) {
this.name = n;
this.id = i;
this.numberOfAllowedBooksToBorrow = nb;
}
public String getName(){ return name; }
public int getId(){ return id; }
public int getNumberOfAllowedBooksToBorrow(){ return numberOfAllowedBooksToBorrow; }
public String toString(){ return name; }
}
同样的方式也可用于PermissionType
关于java - 类图的实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55865842/