And the last piece I want you to see here, and then I'll let you go is, notice now how that encapsulation, that binding things together has really helped me.
我想要的那么干净,最后一点要给大家讲的是,也就是下课前讲的一点,就是请注意这里是怎么封装的,也就是把东西绑定在一起。
Let's be careful here; let's do this for Firm 1 and we'll do Firm 2 in a second.
这里要稍微注意一下,我们先写公司1的然后再写公司2的
And the thing you should notice here is that it's doing a lot of the same things over 2 1 and over again. So, for example, we'll see 2, 1 2 1 here. And 2, 1 here.
在这里你要注意的是,它不断在重复同样的工作,例如我们看这里的1,还有这里的。
That's for another lecture Here they are.
不过这是另一堂课要上的内容了,注意看这里
Such men have no other rule, but that of force and violence," listen to this, "So may be treated as beasts of prey those dangerous and noxious creatures that will be sure to destroy to you " if you fall into their power", so kill them first.
这种人除强力和暴力的法则之外,没有其他法则“,注意这里,“因此可以被当作猛兽,危险和有害的动物看待,要落在它们的爪牙之内,就一定会遭到毁灭,所以先下手为强。
So, sometimes you'll find the Rydberg constant in different forms, but just make sure you pay attention to units because then you won't mess them up, because this is in inverse seconds here, the other Rydberg constant is in joules, so you'll be able to use what you need depending on how you're using that constant.
有时候你们会发现Rydberg常数,会写成不同的形式,但你们要注意,它的单位就不会弄错了,因为这里是秒的倒数,而另一个Rydberg常数是焦耳,所有你可以根据你要怎么使用,这个常数来选择你需要的常数。
And just to look ahead a little bit, you could easily imagine that I might want to not just put a statement in there, what the specs are, I might want to put some constraints. Some specific things to check for, to make sure that you're calling the code right.
这不仅是抽象的概念还有规范的概念,我们再往前看看,你可以简单的想象得到,我不仅仅是想在这里加一个声明,这些规范说明中我还想加一些约束,我们要注意一些特殊的事情。
there that we want to highlight. In particular, -- notice-- let me highlight it for you, if I can find it with the wrong glasses on-- we've got these return commands.
这里还有一些我们要引起注意的变化,特别是注意这个,让我给你们强调一下-,看看我能不能戴着这副度数不对的眼镜。
Let's just be careful here, what does it mean to say that 2 dominates 1?
这里要注意,策略2优于1意味着什么
So this is an 'in shoes', be careful where we are here, this is an 'in shoes in shoes' argument, at which point you might want to invent the sock.
所以这是一个不断换位思考式的过程,注意一下这里的措辞,这是一个换位再换位思考的过程,说明我们也要换来换去思考
So, for example: in this case, my list is a bunch of integers. And one of the things I could take advantage of, is I'm only going to need a finite amount of space to represent an integer.
列表是一系列整数,要注意的这里的优势能够,用有限的空间来表示整数,例如,如果我想要操作。
I'm going to print here the list if we go into it, and print of the when we're done and then just return that.
注意接下我来我要做的事,运行到这里时会打印列表,并且当处理完成后会打印返回的列表。
But notice what this does. The first thing it does is, it says, let's check and make sure x is greater than or equal to 0. If it isn't, notice what's going to happen. None of that block is going to get executed, and it's going to come down here and print out a useful piece of information, which says, hey, you gave me a negative number. I don't know how to do this.
做的是和以前一样的事情,但是注释它做了什么,第一件做的事情就是,程序说,要去检查并且确信x是大于等于0的,如果不是的话,请注意会发生什么,下面的代码都不会被执行,程序会到这里来然后显示一些有用的信息,信息会说,嘿,你给了我一个负数,我不知道该怎么弄这个了。
First of all, two parameters. It's OK. All it says is, when I call this, I need to pass in two parameters for this to work. All right? Now, if I want to use that, I'm going to use a second piece of code here, called Barnyard. I'm going Barnyard to read in a couple of values, convert them into integers, and then I'm going to use solve to get a solution out.
注意我得到了什么,第一,两个参数,它的意思就是我调用这个函数,我得给它输入两个参数,明白了吗?,现在如果我要使用它我得用,这里的第二段代码,也叫,我将读入一组值,将它们转化为整型,然后我会用solve得到一个解决方案。
应用推荐