英文:
How to declare UML class diagram scanner scan declaration?
问题
你好,在 UML 类图中声明 Scanner 的适当方式是这样的:
+scan: Scanner 或者 +scan: Scanner(System.in),或者其他方式。此外,还有其他需要添加的内容吗?哦,是的,我正在表示 Java。
谢谢
英文:
Hi what is the proper way to declare a scanner on a uml class diagram, like this
+scan: Scanner or +scan: Scanner(System.in) or something else. Also anything else I should add? Oh yeah I'm representing java.
Thanks
答案1
得分: 4
如果我理解正确,scan 是一个类的属性,Scanner(System.in)
是你初始化它的方式(默认值)
如在 formal/2017-12-05 第 9.5.4 节第 113 页所指定的那样:
[<visibility>] [‘/’] <name> [‘:’ <prop-type>] [‘[‘ <multiplicity-range> ‘]’]
[‘=’ <default>] [‘{‘ <prop-modifier > [‘,’ <prop-modifier >]* ’}’]
首先要注意的是可见性,‘+’ 表示 public,你确定你要将属性设置为 public 吗?这是危险的,因为这意味着它可以从任何其他类进行修改。
除此之外,如果你只想指示其可见性和类型:+scan : Scanner
如果你还想指示其默认值:+scan : Scanner = Scanner(System.in)
因此,+scan: Scanner(System.in)
是错误的。
英文:
If I well understand scan is an attribute of a class and Scanner(System.in)
the way you initialize it (default value)
As specified in the formal/2017-12-05 §9.5.4 from page 113 the notation is :
[<visibility>] [‘/’] <name> [‘:’ <prop-type>] [‘[‘ <multiplicity-range> ‘]’]
[‘=’ <default>] [‘{‘ <prop-modifier > [‘,’ <prop-modifier >]* ’}’]
A first remark concern the visibility, '+' means public, are you sure you want your attribute public ? This is dangerous because that means it can be modified from any other class.
Out of that if you want to only indicate its visibility and type : +scan : Scanner
If you want to also indicate its default value : +scan : Scanner = Scanner(System.in)
So +scan: Scanner(System.in)
is wrong
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论