谁能告诉我它是什么样的模式? [英] Can anyone tell me what pattern it is?

查看:63
本文介绍了谁能告诉我它是什么样的模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我们正在为新的电子干手器编写软件。干燥器有一个光传感器,可以确定每当有人的手放在它下面。这会触发烘干机开始吹热风。也可以通过设备上的按钮触发烘干机。一旦装置开始吹气,我们不希望额外推动按钮或光传感器的触发器来延长吹气周期。



选择最合适的设计模式用于解决问题并显示它是如何应用的。特别是,显示一个合适的类图和足够的代码片段来说明你使用模式来解决问题。

We are writing the software for a new electronic hand dryer. The dryer has a light sensor which can determine whenever someone's hands are placed under it. This triggers the dryer to start blowing hot air. The dryer can also be triggered via a push button on the unit. Once the unit starts blowing, we do not want additional pushes of the button or triggers of the light sensor to extend the air blowing cycle.

Select the most appropriate design pattern to use to address the problem and show how it is applied. In particular, show an appropriate class diagram(s) and enough code fragments to illustrate your use of the pattern to solve the problem.

推荐答案

我们不做你的功课:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!


为了将来的使用和答案,请使用这种模式:

http://en.wikipedia.org/wiki/Command_pattern



设计模式一开始很难。关键是选择问题中的部分。它表示打开或关闭。即使我知道或不知道模式,我也会选择开关部分并完成讲师给你的所有设计模式10-20。讲师将使用某些单词来触发应该使用的模式。这不是一个技巧问题或者你必须非常努力地研究的东西。这些都是你给出的IT笔记。



在这种情况下,命令模式有一个开关,你的吹风机有一个事件并触发一些东西。然后它有一个状态(可能的其他设计模式)。



其余的即使你是对的还是稍微错了,讲师会给你这个尝试的标记。如果你说单身,建造者或其他没有意义的东西(他将有一个设计模式列表)他会标记你。



如果你在重复今年同样的课程,至少你会知道如何得到答案!
For future use and answers, use this pattern:
http://en.wikipedia.org/wiki/Command_pattern

Design patterns are hard at start. The key is to pick the parts in the question. It says switch on or off. Even if I do or don't know the pattern, I would take the switch part and go through all the design patterns 10-20 the lecturer has given you. The examples the lecturer will have certain words that trigger what pattern should be used. It won't be a trick question or something you have to research very hard. It's all in the IT notes you were given.

In this case, the command pattern has a switch, your hairdryer has an event and triggers something. It then has a state (possible other design pattern).

The rest even if you are right or "slightly" wrong, the lecturer will give you marks for the attempt. If you said singleton, builder or something that does not make sense (which he will have a list of design patterns) he will mark you down.

If you are repeating this year the same course, at least you'll know how to get the answer!


这篇关于谁能告诉我它是什么样的模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆