UML 类图中带参数的构造函数

发布于 2024-09-28 22:38:22 字数 297 浏览 3 评论 0原文

如何为带参数的构造函数创建 uml 类图?

执行

  • 对于默认构造函数(无参数),您可以在图表和伪代码中

policyholder()对于带参数的构造函数,您会执行相同的操作:

  • policyholder(策略编号、服务类和客户年龄) 用于类图和伪代码。

它还要求将每个属性初始化为可以实例化该类型的对象的值。如果保单编号不在1000到999之间(含1000和999),则将保单编号设置为0。(保单编号是属性)

How would you create an uml class diagram for constructors with parameters?

For default constructors (no parameters) you do

  • policyholder() for the diagram and in the pseudo-code

For constructors with parameters would you do the same thing:

  • policyholder (policynumber, service class, and customer age) for class diagrams and pseudo-code.

It also asked to initialize each attribute to value where an object of this type can be instantiated. If a policy number is not between 1000 and 999 inclusive, then set the policy number to 0. (policy number is attribute)

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

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

发布评论

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

评论(1

又怨 2024-10-05 22:38:22

常见的方法是像方法一样编写构造函数,并简单地省略返回类型。

在此处输入图像描述

如果你想更加清晰,可以添加 <>> 在前面。

The common way is to write constructors like methods and simply omit the return type.

enter image description here

If you want to be extra clear, you can add <<constructor>> in front.

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