Advertisement
ErolKZ

Untitled

Oct 31st, 2021
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1.  
  2. class Storage {
  3.  
  4. constructor (capacity) {
  5.  
  6. this.capacity = capacity;
  7.  
  8. this.storage = [];
  9.  
  10. this.totalCost = 0;
  11.  
  12. }
  13.  
  14.  
  15. addProduct (obj) {
  16.  
  17. this.storage.push(JSON.stringify(obj));
  18.  
  19. this.capacity -= obj.quantity;
  20.  
  21. this.totalCost += obj.price * obj.quantity;
  22.  
  23. }
  24.  
  25. getProducts() {
  26.  
  27. return this.storage.join('\n');
  28.  
  29. }
  30.  
  31.  
  32.  
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement