课程: Node.js: Design Patterns

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Implementing the storage class

Implementing the storage class

- [Instructor] In the last lesson, we added code to the store to use a storage class that implements the chain of responsibility design pattern. In this lesson, we'll code the storage class so that we can search for inventory items in multiple locations. I'm inside of the exercise files for chapter four, chapter four lesson two, and I'm inside of the start folder. Within this folder I'm going to go ahead and add a new file called storage.js. And in our storage file I'm going to go ahead and create a new class, storage, and we'll go ahead and give it a constructor. And this class will take in the name of the storage location and also the inventory for that location. And then finally we also are taking in a delivery time. And I am going to default the delivery time to zero and the inventory to an empty array in case those values are not sent. Those this.name is going to equal our name, this.inventory is going to equal our…

内容