Skip to content

Instantly share code, notes, and snippets.

@kyktommy
Created October 11, 2012 16:53
Show Gist options
  • Save kyktommy/3873818 to your computer and use it in GitHub Desktop.
Save kyktommy/3873818 to your computer and use it in GitHub Desktop.
class Sale {
int amount;
Sale(int a) {
amount = a;
}
int getAmount() {
return this.amount;
}
}
interface Payment {
public int calcAmount();
}
class CreditCardPayment implements Payment {
int amount;
CreditCardPayment() {
this.amount = 500;
}
public int calcAmount(Sale sale) {
return amount - sale.getAmount();
}
public boolean authorize() {
return false;
}
}
// not done
class CashPayment {
int amountTendered;
boolean changeGiven;
public int calcAmount() {
return 100;
}
}
class app {
public static void main(String[] args) {
CreditCardPayment c = new CreditCardPayment();
System.out.println( c.calcAmount(new Sale(40)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment