Created
October 11, 2012 17:04
-
-
Save kyktommy/3873944 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 app { | |
public static void main(String[] args) { | |
CreditCardPayment c = new CreditCardPayment(); | |
System.out.println("need to pay: 50" + c.calcAmount() ); | |
} | |
} |
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
public class CreditCardPayment implements Payment { | |
int amount; | |
CreditCardPayment() { | |
this.amount = 500; | |
} | |
public int calcAmount() { | |
return amount - sale.getAmount(); | |
} | |
public boolean authorize() { | |
return true; | |
} | |
} |
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
public interface Payment { | |
public Sale sale = new Sale(50); | |
public int calcAmount(); | |
} |
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
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