如何将这个 OOP 作为 ColdFusion 组件 (CFC) 来执行?
有人能够解释以下问题要求我做什么吗?我不需要了解代码,只需根据 Coldfusion 进行不同的解释就可以了,这样我也许就能理解他们要求我写的内容。
据我所知,ColdFusion 没有“属性”,这必须使用 CFC 进行模拟。
创建一个具有以下特征的类
- 它应该有 3 个数据成员(1 个整数、1 个字符串和 1 个双精度) 构造时,对象应该分别使用以下值初始化其三个数据成员:10、“hello world”和 1.234
- 它应该包含允许使用该类的使用者检索和修改任何数据成员值的属性。
- 它应该有一个方法,允许消费者在一次调用中设置所有 3 个值。
创建一个方法,该方法创建问题 4 中指定的类的新实例:(您不必编写任何代码来测试该过程)
- 使用类提供的属性 获取每个数据成员的值 并将值输出到调试 窗口使用虚构的和 全局可用的方法 WriteToDebugWindow()。
WriteToDebugWindow() 接受一个字符串 其值输出到的参数 调试窗口。由于这个方法 是虚构的,因此将是 无论什么语言都足够 您选择参加此测试。 - 使用类提供的属性 将每个数据成员修改为值 您选择的然后输出 您更改的属性的值 使用到调试窗口 和以前一样,WriteToDebugWindow()。
- 使用类提供的属性 获取每个数据成员的值 并将值输出到调试 窗口使用虚构的和 全局可用的方法 WriteToDebugWindow()。
Would some one be able to explain what the following questions are asking me to do. I don't need to know the code, just a different explanation in terms of Coldfusion would be good so I might be able to understand what they are asking me to write.
As far as I know ColdFusion doesn't have "properties", This has to be simulated with a CFC.
Create a class with the following characteristics
- It should have three data members (one integer, one string, and one double) When constructed the object should initialize its three data members with the following values respectively: 10, "hello world", and 1.234
- It should contain properties that allow a consumer using the class to retrieve and modify any of the data member values.
- It should have a method that allows the consumer to set all 3 values in one call.
Create a method which creates a new instance of the class specified in question 4: (you do not have to write any code to test the procedure)
- Use properties provided by the class
to get the value of each data member
and output the value to the debug
window using the fictional and
globally available method of
WriteToDebugWindow().
WriteToDebugWindow() takes one string
parameter whose value is outputted to
the debug window. Since this method
is fictional it will therefore be
sufficient no matter what language
you choose to take this test in. - Use properties provided by the class
to modify each data member to values
of your choosing and then output the
values of the properties you changed
to the debug window using
WriteToDebugWindow() as before.
- Use properties provided by the class
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这充满了家庭作业的味道,但需要从沉闷的一天中休息一下。
下面是使用
隐式 getter 和 setter 的 ColdFusion 9 特定实现。 CFC 会覆盖整数和双精度成员的这些 setter,以执行 ColdFusion 本身不执行的数据类型验证。BrownPeanut.cfc
BrownPeanut.cfm
This reeks of homework, but needed a break from a dreary day.
Below is a ColdFusion 9 specific implementation using
<cfproperty/>
implicit getters and setters. The CFC overrides those setters for the integer and double members to perform data type validation ColdFusion does not do natively.BrownPeanut.cfc
BrownPeanut.cfm
因此,您需要一个 init 方法,将您的值初始化到 this 范围,然后返回 this。返回类型应类似于“path.to.yourCFC”。您将需要单独的 getter 和 setter 方法,以及一种可以更新所有这些方法的方法。后一种方法应该只调用各个设置器。
So you'll need an init method that initialises your values into the this scope, then returns this. The returntype should be like "path.to.yourCFC". You'll need individual getter and setter methods, as well as one method that will update them all. The latter method should just call the individual setters.