Last active
April 30, 2019 19:41
-
-
Save tamunoibi/36539421eec73c24d5b7414280058258 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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