* Creating classes: * * Class declaration: class Name {} * Class expression: const Name = class {}
| 6 | */ |
| 7 | |
| 8 | class Backpack { |
| 9 | constructor( |
| 10 | // Defines parameters: |
| 11 | name, |
| 12 | volume, |
| 13 | color, |
| 14 | pocketNum, |
| 15 | strapLengthL, |
| 16 | strapLengthR, |
| 17 | lidOpen |
| 18 | ) { |
| 19 | // Define properties: |
| 20 | this.name = name; |
| 21 | this.volume = volume; |
| 22 | this.color = color; |
| 23 | this.pocketNum = pocketNum; |
| 24 | this.strapLength = { |
| 25 | left: strapLengthL, |
| 26 | right: strapLengthR, |
| 27 | }; |
| 28 | this.lidOpen = lidOpen; |
| 29 | } |
| 30 | // Add methods like normal functions: |
| 31 | toggleLid(lidStatus) { |
| 32 | this.lidOpen = lidStatus; |
| 33 | } |
| 34 | newStrapLength(lengthLeft, lengthRight) { |
| 35 | this.strapLength.left = lengthLeft; |
| 36 | this.strapLength.right = lengthRight; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | export default Backpack; |
nothing calls this directly
no outgoing calls
no test coverage detected