Andela Shopping Cart Test created by iamuchejude - https://repl.it/@iamuchejude/Andela-Shopping-Cart-Test
class ShoppingCart {
constructor() {
this.quantity = 100;
this.total = 0;
this.items = {};
}
addItem(item_name, quantity, price) {
this.total += price * quantity;
this.items[item_name] = quantity
}
removeItem(item_name, quantity, price) {
if(this.items[item_name] in this.items) {
return 'Item is not in cart';
} else {
this.total -= price * quantity;
this.items[item_name] = this.items[item_name] - quantity;
}
}
checkout(cash_paid) {
if(cash_paid < this.total) {
return 'Cash paid not enough';
} else {
return cash_paid - this.total;
}
}
}
class Shop extends ShoppingCart {
removeItem() {
this.quantity -= 1;
return this.quantity;
}
}