具有聚合和泛化的类图

发布于 2024-08-21 01:57:37 字数 160 浏览 10 评论 0原文

我正在做一个大学项目,我有以下我无法解决的问题。

我有一个名为 Employee 的课程 由此我概括了两类承包商雇员和永久雇员。

现在我有一个由两种类型的员工组成的团队,所以我计划使用聚合。

我是否必须将团队类连接到两个子类或员工类?

谢谢

I am working on a university project and i have the following problem i can not figure out.

I have a class Called Employee
from this i generalize two classes Contractor employee and Permanent Employee.

Now i have a team that is made by both types of Employee so i am planning to use aggregation.

Do i have to connect the team class to the two subclasses or to the employee class?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

人心善变 2024-08-28 01:57:37

到员工班。团队类将有一个员工列表;它不会关心他们实际上是 ContractorEmployees、PermanentEmployees 或 FooEmployees。

To the employee class. The team class will have a list of Employees; it won't care it they're actually ContractorEmployees, PermanentEmployees, or FooEmployees.

寒尘 2024-08-28 01:57:37

嗯,有趣的问题...如果您的 Team 类仅指 Employee,那么您将来可以扩展到其他类型的员工(TeamLeads、Managers 等...)。如果您将 Team 类绑定到 Contractor 和 PermanentEmployee,那么您实际上是在说一个 Team 可以有 Contractors、Perm.Employees,并且没有其他内容!但也许这就是您想要的...

Hmm interesting question... If your Team class only refers to Employee, you'd be able to expand in the future to other types of Employees (TeamLeads, Managers, etc...). If you bind your Team class to Contractor and PermanentEmployee, you are effectively saying that a Team can have Contractors, Perm.Employees, and nothing else! But maybe that's what you want...

南风起 2024-08-28 01:57:37

看一下这里:组合关联

在 UML 2 中,聚合将用空心菱形显示。

Take a look here: Composition Associations

In UML 2, aggregation would be shown with an open diamond.

仅此而已 2024-08-28 01:57:37

不要在团队和员工或其子类型之间使用聚合。 Team 类有一个属性“Members”,它是员工的集合。这样,团队可以拥有员工子类型的任意组合,包括以后添加的任何其他子类型。

Don't use aggregation between Team and Employees or their subtypes. The Team class has a attribute 'Members' which is a collection of Employees. This way the Team can have any combination of Employee subtypes including any other subtypes added later.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文