Advertisement
ErolKZ

Untitled

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