Skip to content

Instantly share code, notes, and snippets.

@hsynkrcf
Last active November 9, 2022 23:46
Show Gist options
  • Save hsynkrcf/005749b69344cd5ede30c7c9ae88158c to your computer and use it in GitHub Desktop.
Save hsynkrcf/005749b69344cd5ede30c7c9ae88158c to your computer and use it in GitHub Desktop.
OCP
public class PhoneFactory
{
public void MakePhone(Phone phone)
{
switch (phone.Type)
{
case PhoneType.Iphone:
MakeIphone((Iphone)phone);
break;
case PhoneType.Samsung:
MakeSamsung((Samsung)phone);
break;
}
}
private void MakeIphone(Phone phone)
{
Console.WriteLine("Iphone Created\n");
}
private void MakeSamsung(Phone phone)
{
Console.WriteLine("Samsung Created\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment