Last active
November 9, 2022 23:46
-
-
Save hsynkrcf/005749b69344cd5ede30c7c9ae88158c to your computer and use it in GitHub Desktop.
OCP
This file contains 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
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