Skip to content

Instantly share code, notes, and snippets.

@kyktommy
Created October 11, 2012 17:04
Show Gist options
  • Save kyktommy/3873944 to your computer and use it in GitHub Desktop.
Save kyktommy/3873944 to your computer and use it in GitHub Desktop.
class app {
public static void main(String[] args) {
CreditCardPayment c = new CreditCardPayment();
System.out.println("need to pay: 50" + c.calcAmount() );
}
}
public class CreditCardPayment implements Payment {
int amount;
CreditCardPayment() {
this.amount = 500;
}
public int calcAmount() {
return amount - sale.getAmount();
}
public boolean authorize() {
return true;
}
}
public interface Payment {
public Sale sale = new Sale(50);
public int calcAmount();
}
public class Sale {
int amount;
Sale(int a) {
amount = a;
}
int getAmount() {
return this.amount;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment