我目前在了解UML中的三元关联方面遇到了一些麻烦。我得到二进制的,但我不确定如何在三元组上进行多重性。我正在做我从大学学习的练习,目前的练习是这样的:
一个部门可能会销售许多产品,但仅限于一个市场。在市场上,一个产品只能由一个部门出售。
我已经阅读了不同的消息来源,关于我应该如何思考这两个类别中的一对我并不是想弄清多重性,但是我的大脑不是&#39得到它。帮助我Overflow Kenobi,你是我唯一的希望。
答案 0 :(得分:6)
在三元关联的多重性规范中似乎存在一些模糊性。另请参阅this paper
但我明白这样:
多重性表示对于任何给定的链接实例元组,此关联中可能存在实例的次数。
在任何特定的家庭中,必须有一个父亲,一个母亲和零个或多个孩子。
如果我们将这个应用到您的案例中,那么我会遇到这样的事情:
对于任何给定的产品,必须只有一个市场,一个部门和一个或多个产品
这似乎或多或少地满足了所有约束
我不认为它是防水的,但正如文章已经说过的那样,UML没有足够的工具来制作防水设计,只有两端的多重性。因此,为了更好地衡量,您的约束也应该建模为UML约束。
免责声明:三元协会对于学术讨论非常好,但并未真正用于(IT)行业,可能是因为它们很难理解。
答案 1 :(得分:3)
这个非特定的三元协会只是告诉你关系在哪里
Market
控件Department
- Product
,Department
控件Market
- Product
和Product
控件Department
- Market
。没有关于单个类如何控制其他两个的陈述。
UML规范没有详细定义三元运算符。所以使用该元素似乎风险自负。你可以责怪OMG使用但不是将其定义为
任何关联都可以绘制为菱形(大于线上的终结符),每个协会成员都有一条实线,并将钻石连接到结尾类型的分类器。具有两个以上目标的协会只能以这种方式绘制。
和p上的图片中的单个示例。 202。
简单关联类
告诉您Product
位于Department
和Market
之间,其中多重性1
表示只有Market
个Department
Product
。这更符合您的要求。
N.B。分开关于要求的头发并没有多大意义,因此"是Market
没有 func addExplosion(explosionNode: SKSpriteNode, atPosition position: CGPoint) {
explosion = SKSpriteNode(texture: explosionTex)
//Animation
heroFlyTexturesArray = [SKTexture(imageNamed: "explosion1_0001.png"), SKTexture(imageNamed: "explosion1_0002.png"), SKTexture(imageNamed: "explosion1_0003.png"), SKTexture(imageNamed: "explosion1_0004.png"), SKTexture(imageNamed: "explosion1_0005.png"), SKTexture(imageNamed: "explosion1_0006.png"), SKTexture(imageNamed: "explosion1_0007.png"), SKTexture(imageNamed: "explosion1_0008.png"), SKTexture(imageNamed: "explosion1_0009.png"), SKTexture(imageNamed: "explosion1_0010.png"), SKTexture(imageNamed: "explosion1_0011.png"), SKTexture(imageNamed: "explosion1_0012.png"), SKTexture(imageNamed: "explosion1_0013.png"), SKTexture(imageNamed: "explosion1_0014.png"), SKTexture(imageNamed: "explosion1_0015.png"), SKTexture(imageNamed: "explosion1_0016.png"), SKTexture(imageNamed: "explosion1_0017.png"), SKTexture(imageNamed: "explosion1_0018.png"), SKTexture(imageNamed: "explosion1_0019.png"), SKTexture(imageNamed: "explosion1_0020.png"), SKTexture(imageNamed: "explosion1_0021.png"), SKTexture(imageNamed: "explosion1_0022.png"), SKTexture(imageNamed: "explosion1_0023.png"), SKTexture(imageNamed: "explosion1_0024.png"), SKTexture(imageNamed: "explosion1_0025.png"), SKTexture(imageNamed: "explosion1_0026.png"), SKTexture(imageNamed: "explosion1_0027.png"), SKTexture(imageNamed: "explosion1_0028.png"), SKTexture(imageNamed: "explosion1_0029.png"), SKTexture(imageNamed: "explosion1_0030.png"), SKTexture(imageNamed: "explosion1_0031.png"), SKTexture(imageNamed: "explosion1_0032.png"), SKTexture(imageNamed: "explosion1_0033.png"), SKTexture(imageNamed: "explosion1_0034.png"), SKTexture(imageNamed: "explosion1_0035.png"), SKTexture(imageNamed: "explosion1_0036.png"), SKTexture(imageNamed: "explosion1_0037.png"), SKTexture(imageNamed: "explosion1_0038.png"), SKTexture(imageNamed: "explosion1_0039.png"), SKTexture(imageNamed: "explosion1_0040.png"), SKTexture(imageNamed: "explosion1_0041.png"), SKTexture(imageNamed: "explosion1_0042.png"), SKTexture(imageNamed: "explosion1_0043.png"), SKTexture(imageNamed: "explosion1_0044.png"), SKTexture(imageNamed: "explosion1_0045.png"), SKTexture(imageNamed: "explosion1_0046.png"), SKTexture(imageNamed: "explosion1_0047.png"), SKTexture(imageNamed: "explosion1_0048.png"), SKTexture(imageNamed: "explosion1_0049.png"), SKTexture(imageNamed: "explosion1_0050.png"), SKTexture(imageNamed: "explosion1_0051.png"), SKTexture(imageNamed: "explosion1_0052.png"), SKTexture(imageNamed: "explosion1_0053.png"), SKTexture(imageNamed: "explosion1_0054.png"), SKTexture(imageNamed: "explosion1_0055.png"), SKTexture(imageNamed: "explosion1_0056.png"), SKTexture(imageNamed: "explosion1_0057.png"), SKTexture(imageNamed: "explosion1_0058.png"), SKTexture(imageNamed: "explosion1_0059.png"), SKTexture(imageNamed: "explosion1_0060.png"), SKTexture(imageNamed: "explosion1_0061.png"), SKTexture(imageNamed: "explosion1_0062.png"), SKTexture(imageNamed: "explosion1_0063.png"), SKTexture(imageNamed: "explosion1_0064.png"), SKTexture(imageNamed: "explosion1_0065.png"), SKTexture(imageNamed: "explosion1_0066.png"), SKTexture(imageNamed: "explosion1_0067.png"), SKTexture(imageNamed: "explosion1_0068.png"), SKTexture(imageNamed: "explosion1_0069.png"), SKTexture(imageNamed: "explosion1_0070.png"), SKTexture(imageNamed: "explosion1_0071.png"), SKTexture(imageNamed: "explosion1_0072.png"), SKTexture(imageNamed: "explosion1_0073.png"), SKTexture(imageNamed: "explosion1_0074.png"), SKTexture(imageNamed: "explosion1_0075.png"), SKTexture(imageNamed: "explosion1_0076.png"), SKTexture(imageNamed: "explosion1_0077.png"), SKTexture(imageNamed: "explosion1_0078.png"), SKTexture(imageNamed: "explosion1_0079.png"), SKTexture(imageNamed: "explosion1_0080.png"), SKTexture(imageNamed: "explosion1_0081.png"), SKTexture(imageNamed: "explosion1_0082.png"), SKTexture(imageNamed: "explosion1_0083.png"), SKTexture(imageNamed: "explosion1_0084.png"), SKTexture(imageNamed: "explosion1_0085.png"), SKTexture(imageNamed: "explosion1_0086.png"), SKTexture(imageNamed: "explosion1_0087.png"), SKTexture(imageNamed: "explosion1_0088.png"), SKTexture(imageNamed: "explosion1_0089.png"), SKTexture(imageNamed: "explosion1_0090.png")]
let heroFlyAnimation = SKAction.animate(with: heroFlyTexturesArray, timePerFrame: 0.01)
let flyHero = SKAction.repeat(heroFlyAnimation, count: 1)
// repeatForever(heroFlyAnimation)
explosion.run(flyHero, withKey: "explosion")
explosion.position = position
explosion.size.height = 130
explosion.size.width = 200
explosionObject.addChild(explosion)
if explosionObject.frame(flyHero) == 90 {}
}
}
"。这些是在修复模型之前需要与领域专家讨论的细节。
答案 2 :(得分:2)
Geert Bellekens答案中的模型是正确的,但他的解释却令人困惑。三元协会"提供"具有多重性(基数约束)不能用语句
来解释
对于任何给定的产品,必须只有一个市场,一个部门和一个或多个产品
而是说明
部门和产品的组合仅与一个市场相关联 市场和产品的组合只与一个部门相关联
答案 3 :(得分:0)
三级和更高级别的关联应建模为符合ISO标准,其中标的两端相反。 因此,对于二进制关联,请使用拥有端点的通常含义。
如果遇到三元或更高级别的关联,智能工具应切换解析模式。
已经证明您可以将N元关联分解为很多二进制关联,因此通常避免使用这些N元。