今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Constructor pattern
- [Instructor] Similar to the class prototype pattern, the constructor pattern is one step further from the class pattern, where we leverage a class created to create an extended class from it. Let me demonstrate. So we'll leverage our car class here, and as you can see we already have a constructor, but the actual pattern itself is something else. So the constructor allows us to create a new object from the class. But what if we would like to create an SUV class and extend this class from it? And that's what the constructor pattern is and why you would use it. So let's go ahead and do that. So the first thing I'm going to do is create a new class called SUV. And we're going to extend the car class. So basically we're leveraging the constructor we already have in this class, and then we'll extend it with other items. So let's go ahead and do that by creating the class and then the constructor will still have doors…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。