Skip to content

Instantly share code, notes, and snippets.

@jasongorman
Created April 15, 2021 07:33
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/37e707ac8afc10e52caac60d612b1410 to your computer and use it in GitHub Desktop.
Save jasongorman/37e707ac8afc10e52caac60d612b1410 to your computer and use it in GitHub Desktop.
public class CD {
private int stock;
private final double price;
public CD(int stock, double price) {
this.stock = stock;
this.price = price;
}
public int getStock() {
return stock;
}
public void buy(int quantity, CreditCard card) {
card.charge(price * quantity);
stock = stock - quantity;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment