Skip to content

Instantly share code, notes, and snippets.

@jasongorman
Created July 28, 2019 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasongorman/eb4fefa0fbfa25b22a4dd24fea82d3ee to your computer and use it in GitHub Desktop.
Save jasongorman/eb4fefa0fbfa25b22a4dd24fea82d3ee to your computer and use it in GitHub Desktop.
buy(payments, customer, creditCard) {
if(this.stock == 0){
throw new OutOfStockError();
}
let paymentAccepted = payments.process(this.price, creditCard);
if(paymentAccepted){
this.stock -= 1;
customer.cdCollection.push(this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment