Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public class CompactDisc {
private int stock;
private double price;
private Payments payments;
public CompactDisc(int stock, double price, Payments payments) {
this.stock = stock;
this.price = price;
this.payments = payments;
public int getStock() {
return stock;
public double getPrice() {
return price;
public Payments getPayments() {
return payments;
int buy(String creditCardNumber) {
int stock = getStock();
if(getPayments().process(getPrice(), creditCardNumber) == PaymentResponse.ACCEPTED)
return stock;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment