| 1 | class Backpack { |
| 2 | constructor( |
| 3 | name, |
| 4 | volume, |
| 5 | color, |
| 6 | pocketNum, |
| 7 | strapLengthL, |
| 8 | strapLengthR, |
| 9 | lidOpen, |
| 10 | dateAcquired, |
| 11 | image |
| 12 | ) { |
| 13 | this.name = name; |
| 14 | this.volume = volume; |
| 15 | this.color = color; |
| 16 | this.pocketNum = pocketNum; |
| 17 | this.strapLength = { |
| 18 | left: strapLengthL, |
| 19 | right: strapLengthR, |
| 20 | }; |
| 21 | this.lidOpen = lidOpen; |
| 22 | this.dateAcquired = dateAcquired; |
| 23 | this.image = image; |
| 24 | } |
| 25 | toggleLid(lidStatus) { |
| 26 | this.lidOpen = lidStatus; |
| 27 | } |
| 28 | newStrapLength(lengthLeft, lengthRight) { |
| 29 | this.strapLength.left = lengthLeft; |
| 30 | this.strapLength.right = lengthRight; |
| 31 | } |
| 32 | backpackAge() { |
| 33 | let now = new Date(); |
| 34 | let acquired = new Date(this.dateAcquired); |
| 35 | let elapsed = now - acquired; // elapsed time in milliseconds |
| 36 | let daysSinceAcquired = Math.floor(elapsed / (1000 * 3600 * 24)); |
| 37 | return daysSinceAcquired; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | export default Backpack; |
nothing calls this directly
no outgoing calls
no test coverage detected