Skip to content

Instantly share code, notes, and snippets.

@tamunoibi
Last active April 30, 2019 19:41
Show Gist options
  • Save tamunoibi/36539421eec73c24d5b7414280058258 to your computer and use it in GitHub Desktop.
Save tamunoibi/36539421eec73c24d5b7414280058258 to your computer and use it in GitHub Desktop.
class ShoppingCart {
constructor () {
this._total = 0;
this._item = {};
}
addItem(itemName, quantity, price) {
this._total += price;
//confirm if you should use dot notation or bracket notation to access itemName.
item.[itemName] = quantity;
}
removeItem(itemName, quantity, price) {
if (quantitiy > this._quanity) {
item.itemName = null;
this.total -= price;
}
checkout(cashPaid) {
if (cashPaid < this._price) {
return "Cash paid not enough";
} else {
return this._price - cashPaid;
}
}
class Shop extends ShoppingCart {
constructor (name) {
super(name);
this._quantity = 100;
}
removeItem() {
this._quantity -= 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment