Skip to content

Instantly share code, notes, and snippets.

@ssukhpinder
Created May 24, 2021 06:31
Show Gist options
  • Save ssukhpinder/83bf043816237f0ce5a7f57aee4e2aa3 to your computer and use it in GitHub Desktop.
Save ssukhpinder/83bf043816237f0ce5a7f57aee4e2aa3 to your computer and use it in GitHub Desktop.
public class AccountFactory : IAccountFactory
{
public AccoutType GetAccoutType(string accountName)
{
if (accountName.Equals("SAVINGS", StringComparison.OrdinalIgnoreCase))
{
return new SavingsAccount();
}
else if (accountName.Equals("CURRENT", StringComparison.OrdinalIgnoreCase))
{
return new CurrentAccount();
}
else
{
throw new ArgumentException("Invalid account name");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment