Created
October 11, 2012 16:53
-
-
Save kyktommy/3873818 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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