Skip to content

Instantly share code, notes, and snippets.

@yemrekeskin
Last active December 20, 2015 11:49
Show Gist options
  • Save yemrekeskin/6126157 to your computer and use it in GitHub Desktop.
Save yemrekeskin/6126157 to your computer and use it in GitHub Desktop.
Strategy Design Pattern implementation - Payment types (Accounting and Transfer)
public interface ITransferOperation
{
bool DoAccounting();
void Transfer();
}
public class ForeignPayment
:ITransferOperation
{
public bool DoAccounting()
{
throw new NotImplementedException();
}
public void Transfer()
{
throw new NotImplementedException();
}
}
public class DomesticPayment
:ITransferOperation
{
public bool DoAccounting()
{
throw new NotImplementedException();
}
public void Transfer()
{
throw new NotImplementedException();
}
}
public class SepaPayment
: ITransferOperation
{
public bool DoAccounting()
{
throw new NotImplementedException();
}
public void Transfer()
{
throw new NotImplementedException();
}
}
public class Payment
{
private readonly ITransferOperation _transfer;
public Payment (ITransferOperation transfer)
{
this._transfer = transfer;
}
public bool DoAccounting()
{
this._transfer.DoAccounting();
return default(bool);
}
public void Transfer()
{
this._transfer.Transfer();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment