根据下面的代码,你能告诉我如何(如果可能的话)从类Service
中引用类ComputationUnit
中定义的数组吗?
class ComputationUnit {
contains Method[1..*] methods
}
class Method {
String name
String signature
Object sourceCode
contains Parameter[1..*] parameters
}
class Servic e {
contains Comment comment
contains Parameter[1..*] parameters
contains Contract[0..*] contracts
refers Method[] methods //How can I refer to the array defined inside the ComputationUnit class?
}
你不能。这说不通啊。在ComputationUnit
类中不仅定义了一个数组,在ComputationUnit
的每个实例中都定义了一个数组。您需要哪个实例?
你应该这样写:
refers ComputationUnit unit
,然后根据需要从引用到单元访问数组