Created
October 31, 2012 03:23
-
-
Save slimbo/3984607 to your computer and use it in GitHub Desktop.
Hit the Bits! - CFInterface - CF Version
This file contains hidden or 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
| <cfscript> | |
| <!--- IAccount.cfc ---> | |
| interface | |
| { | |
| public numeric function getBalance(); | |
| } | |
| <!--- CheckingAccount.cfc ---> | |
| component implements="IAccount" | |
| { | |
| public numeric function getBalance() | |
| { | |
| return 0; | |
| } | |
| public void function writeCheck(required numeric amount, required string recipient) | |
| { | |
| writeLog("Writing a check to " & recipient & " in the amount of " & amount); | |
| } | |
| } | |
| <!--- SavingsAccount.cfc ---> | |
| component implements="IAccount" | |
| { | |
| public numeric function getBalance() | |
| { | |
| return 0; | |
| } | |
| } | |
| <!--- index.cfm ---> | |
| ExerciseAccount(new CheckingAccount()); | |
| ExerciseAccount(new SavingsAccount()); | |
| any function ExerciseAccount(required IAccount account) | |
| { | |
| writeLog("Balance of this account is #account.getBalance()#"); | |
| account.writeCheck(20, "Mr. Smith"); | |
| } | |
| </cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment