Skip to content

Instantly share code, notes, and snippets.

@slimbo
Created October 31, 2012 03:23
Show Gist options
  • Select an option

  • Save slimbo/3984607 to your computer and use it in GitHub Desktop.

Select an option

Save slimbo/3984607 to your computer and use it in GitHub Desktop.
Hit the Bits! - CFInterface - CF Version
<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