Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Storage {
- constructor (capacity) {
- this.capacity = capacity;
- this.storage = [];
- this.totalCost = 0;
- }
- addProduct (obj) {
- this.storage.push(JSON.stringify(obj));
- this.capacity -= obj.quantity;
- this.totalCost += obj.price * obj.quantity;
- }
- getProducts() {
- return this.storage.join('\n');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement